#include <iostream> #include <vector> using namespace std; int main() { int a[100010]; int t, n, l, r, max, tmp; vector<int> ans; //输入询问次数 cin >> t; for (int i = 0; i < t; i++) { //输入数据数 cin >> n; //输入数据 for (int j = 1; j <= n; j++) { cin >> a[j]; } //初始化条件 ans.clear(); l = 1; max = 0; //遍历数据 for (r = 1; r <= n; r++) { if (r == n || a[r + 1] < a[r]) { tmp = a[r] - a[l]; if (tmp < max) { continue; } if (tmp > max) { ans.clear(); max = tmp; } ans.push_back(l); ans.push_back(r); l = r + 1; } } //打印结果 for (int j = 0; j < ans.size(); j++) { cout << ans[j] << " "; } cout << endl; } return 0; }
全部评论
(1) 回帖