Cod sursa(job #3308518)
| Utilizator | Data | 25 august 2025 19:08:57 | |
|---|---|---|---|
| Problema | Secventa | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.6 kb |
#include <fstream>
#include<deque>
#include<algorithm>
using namespace std;
ifstream cin("secventa.in");
ofstream cout("secventa.out");
int n,k;
deque<pair<int,int>>v;
int main()
{
cin>>n>>k;
int maxi=-999999999,dr=0,x;
for(int i=1;i<=n;i++){
cin>>x;
while(!v.empty() && i-v.front().second>=k)v.pop_front();
while(!v.empty() && v.back().first>=x)v.pop_back();
v.push_back({x,i});
if(i>=k){
if(maxi<v.front().first){
maxi=v.front().first;
dr=i;
}
}
}
cout<<dr-k+1<<" "<<dr<<" "<<maxi;
}
