Cod sursa(job #1710575)

Utilizator theFireLordGeorge Ionescu theFireLord Data 29 mai 2016 12:27:09
Problema Twoton Scor 0
Compilator cpp Status done
Runda Arhiva ICPC Marime 0.6 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(){

    int n;
    cin>>n;


    for(int i=0; i<n;i++){
        cin>>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;
    }

    cout << DP[0];

    return 0;
}