Cod sursa(job #1710577)

Utilizator theFireLordGeorge Ionescu theFireLord Data 29 mai 2016 12:28:03
Problema Twoton Scor 100
Compilator cpp Status done
Runda Arhiva ICPC Marime 0.67 kb
#include <iostream>
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>

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;
}