Pagini recente » Cod sursa (job #1918408) | Cod sursa (job #1219228) | Cod sursa (job #2311752) | Cod sursa (job #2399457) | Cod sursa (job #2472522)
//
// main.cpp
// Secventa
//
// Created by Darius Buhai on 12/10/2019.
// Copyright © 2019 Darius Buhai. All rights reserved.
//
#include <iostream>
#include <fstream>
#define MAXL 500005
using namespace std;
ifstream fin("secventa.in");
ofstream fout("secventa.out");
int main() {
int n, k, a, b[MAXL];
int maxi = -30005, ps, pe, aux1, aux2;
fin>>n>>k;
for(int i=0;i<n;i++){
fin>>a;
aux2 = b[0];
b[0] = a;
for(int j=1;j<min(i+1, k);j++){
aux1 = b[j];
b[j] = min(aux2, a);
aux2 = aux1;
if(j==k-1 && b[j]>maxi){
maxi = b[j];
pe = i+1;
}
}
}
fout<<pe-k+1<<' '<<pe<<' '<<maxi;
return 0;
}