Cod sursa(job #1712700)
Utilizator | Rogoz Bogdan rogoz.bogdan | Data | 3 iunie 2016 13:59:26 |
---|---|---|---|
Problema | Twoton | Scor | 100 |
Compilator | c | Status | done |
Runda | Arhiva ICPC | Marime | 0.63 kb |
//A more compact method, same ease of use
#include <stdio.h>
int a[1000024], n, v;
void wtf_iterativ()
{
int i,minim;
v = 1;
minim = a[n-1];
for(i=n-2; i>=0; i--)
{
if(a[i] < minim)
{
v = (1 + v) % 19997;
minim = a[i];
}
else
{
v = (1 + 2*v) % 19997;
}
}
}
int main()
{
int i;
freopen("twoton.in", "r", stdin);
freopen("twoton.out", "w", stdout);
scanf("%d", &n);
for(i=0; i<n; i++)
scanf("%d", &a[i]);
wtf_iterativ();
printf("%d\n", v);
return 0;
}