Cod sursa(job #1710580)

Utilizator dcutitoiuCutitoiu Adrian-Nicolae dcutitoiu Data 29 mai 2016 12:30:49
Problema Twoton Scor 0
Compilator cpp Status done
Runda Arhiva ICPC Marime 0.55 kb
#include <iostream>

using namespace std;

int DP[100005];
int a[100005];
int wtf[100005];


int main(){


    ifstream in("twoton.in");
    ofstream out("twoton.out");
    int n;
    in>>n;


    for(int i=0; i<n;i++){
        in>>a[i];
    }

    wtf[n-1] = a[n-1];

    for(int i = n-2; i >= 0; i--){
        wtf[i] = a[i] < wtf[i+1] ? a[i] : wtf[i+1];
    }

    DP[n-1] = 1;
    for(int i = n-2; i>=0; i--){
        DP[i] = (1 + (a[i] < wtf[i+1] ? DP[i+1] : 2 * DP[i+1]))%19997;
    }

    out << DP[0];

    return 0;
}