Cod sursa(job #2472515)

Utilizator buhaidarius@gmail.comBuhai Darius [email protected] Data 12 octombrie 2019 15:53:07
Problema Secventa Scor 30
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.72 kb
//
//  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], c[MAXL];
    int maxi = -30005, ps, pe;
    fin>>n>>k;
    for(int i=0;i<n;i++){
        fin>>a;
        c[0] = a;
        for(int j=1;j<min(i+1, k);j++){
            c[j] = min(b[j-1], a);
            if(j==k-1 && c[j]>maxi){
                maxi = c[j];
                pe = i+1;
            }
        }
        for(int j=0;j<k;j++)
            b[j] = c[j];
    }
    fout<<pe-k+1<<' '<<pe<<' '<<maxi;
    return 0;
}