Cod sursa(job #1709052)

Utilizator UAIC_The_RobotsUAIC-Tucar-Onesim-Vintur UAIC_The_Robots Data 28 mai 2016 10:43:04
Problema Twoton Scor 100
Compilator cpp Status done
Runda ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest Marime 0.61 kb
#include <iostream>
#include <fstream>
using namespace std;
#define Nmax 1000100
#define MOD 19997

int a[Nmax], wtf[Nmax];

int main()
{
    freopen("twoton.in", "r", stdin);
    freopen("twoton.out", "w", stdout);

    int i, n, vmin;

    cin >> n;
    for(i = 0; i < n; ++i) cin >> a[i];

    for(vmin = a[n - 1], wtf[n - 1] = 1, i = n - 2; i >= 0; --i)
    {
        if(a[i] < vmin)
        {
            wtf[i] = 1 + wtf[i + 1];
            vmin = a[i];
        }
        else wtf[i] = 1 + 2 * wtf[i + 1];

        wtf[i] %= MOD;
    }

    cout << wtf[0] << '\n';
    return 0;
}