Cod sursa(job #1709128)

Utilizator UAIC_RIP_Han_SoloUAIC BotoIasiByte UAIC_RIP_Han_Solo Data 28 mai 2016 11:00:04
Problema Twoton Scor 100
Compilator cpp Status done
Runda ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest Marime 0.9 kb
#include <bits/stdc++.h>
#include <algorithm>

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ll long long
#define pii pair<int,int>
#define tii tuple <int,int,int>
#define N 1000000
#define mod 19997
#define X first
#define Y second
#define eps 0.0000000001
#define all(x) x.begin(),x.end()
#define tot(x) x+1,x+n+1
using namespace std;


string file="twoton";


int a[N],sol[N],wtf[N],i,n;
int main()
{
    freopen("twoton.in","r",stdin);
    freopen("twoton.out","w",stdout);
    scanf("%d",&n);
    for(i=0; i<n; i++)
        scanf("%d",&a[i]);
    wtf[n-1]=a[n-1];
    sol[n-1]=1;
    for(i=n-2; i>=0; i--)
    {
        sol[i]=1+sol[i+1];
        if(a[i]<wtf[i+1])
            wtf[i]=a[i];
        else
        {
            sol[i]=(sol[i]+sol[i+1])%mod;
            wtf[i]=wtf[i+1];
        }
    }
    printf("%d\n",sol[0]);
    return 0;
}