Cod sursa(job #1711919)

Utilizator enouGhAbu Ras Mohamed Ata Radu enouGh Data 1 iunie 2016 16:20:30
Problema Twoton Scor 100
Compilator cpp Status done
Runda Arhiva ICPC Marime 0.69 kb
#include<bits/stdc++.h>
using namespace std;

int n;
int a[1000024];
int count4 = 0;
int K=0;
long long comparator;
long long count2;
int i;
ifstream fin("twoton.in");
ofstream fout("twoton.out");

int main()
{
        fin>>n;
        for (int i = 0; i < n; ++i)
        {
            fin>>a[i];
        }
        comparator=a[n-1];
        count2=1;
        for(i=n-2;i>=0;i--)
        {
            if(a[i]>comparator)
                count2*=2;
            else
                comparator=a[i];
            count2++;
            if (count2 >= 19997)
            {
                count2 -= 19997;
            }
        }
        fout<<count2;
        return 0;
}