Pagini recente » Cod sursa (job #58921) | Cod sursa (job #1422505) | Cod sursa (job #2216840) | Cod sursa (job #2271449) | Cod sursa (job #3303444)
#include <fstream>
using namespace std;
ifstream in("cuburi2.in");
ofstream out("cuburi2.out");
const int nmax = 250000;
int n, a[nmax + 2], nrq, lf, rg;
int64_t costt[nmax + 2]; int target;
int query(int st, int dr){
int bestt = st;
for(int i = st; i <= dr; i++){
if(a[bestt] < a[i])
bestt = i;
}
return bestt;
}
int main(){
in>>n>>nrq;
for(int i = 1; i <= n; i++)
in>>a[i];
for(int it = 1; it <= nrq; it++){
in>>lf>>rg;
target = query(lf, rg);
out<<target<<" 0\n";
}
return 0;
}