Cod sursa(job #1516134)

Utilizator Lazar_LaurentiuLazar Laurentiu Lazar_Laurentiu Data 2 noiembrie 2015 19:17:15
Problema Secventa Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 1.18 kb
#include <iostream>
#include <fstream>

using namespace std;

int maxt, i, k, minv, j, a[500001], n, c1, c2, bz[500001], s, l[500001];

int main()
{
    ifstream f ("secventa.in");
    ofstream g ("secventa.out");
    f >> n >> k;
    for (i = 1; i <= n; i++) f >> a[i];
    /*s = 1; maxt = -30001; bz[0] = 30001; bz[1] = a[1]; l[1] = 1; j = 1;
    for (i = 2; i <= n; i++) {
        while(a[i] < bz[j] and s <= j)
          j--;
        j++;
        bz[j] = a[i]; l[j] = i;
        if (i - l[s] == k)
            s++;
        if (k <= i)
            if (bz[s] > maxt) {
                c1 = i - k + 1; c2 = i; maxt = bz[s];
            }
    }
    g << c1 << " " << c2 << " " << maxt;*/
    f.close ();
    g.close ();
    return 0;
}
/*
-1 2 3 1 0 8 4 6
         5     8

bz: 4 6
    s d


1
*/
    fi.get();
    getline(fi, sn);
    sn = sn + ' ';
    lsn = sn.size();
    semn = 1;
    v = 0;
    for (j = 0; j < lsn; j++)
    {
        if ('0' <= sn[j] and sn[j] <= '9')
            v = v * 10 + sn[j] - '0';
        else
          if (sn[j] == '-')
            semn = -1;
        else
            a[++i] = v*semn, v = 0, semn = 1;
    }


*/