#include <bits/stdc++.h> using namespace std; #define maxn 1005 int w[maxn]; int mark[maxn]; //记录0-1000数,每个数在w中对应的最近的数 int main() { int T; scanf("%d", &T); while(T--) { int n; scanf("%d", &n); for(int i=0; i<n; i++) scanf("%d", &w[i]); int minNum = maxn; map<int,int> hashw; //记录相同数的最小下标 for(int i=1; i<=n; i++) { if(hashw.find(w[i-1]) == hashw.end()) hashw[w[i-1]] = i; minNum = min(minNum, w[i-1]); } int tmp = 0; for(int i=0; i<=1000; i++) { if(hashw.find(i) != hashw.end()) { mark[i] = i; tmp = i; } else { mark[i] = tmp; } } int q; scanf("%d", &q); int x,y,z; while(q--) { scanf("%d%d%d", &x, &y, &z); int work = x*y*z; if(work < minNum) printf("-1\n"); else { printf("%d %d\n", hashw[mark[work]], mark[work]); } } } return 0; }
全部评论
(1) 回帖