Cod sursa(job #3303444)
| Utilizator | Data | 15 iulie 2025 16:37:43 | |
|---|---|---|---|
| Problema | Cuburi2 | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.6 kb |
#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;
}
