Cod sursa(job #1709238)
| Utilizator | Data | 28 mai 2016 11:25:17 | |
|---|---|---|---|
| Problema | Twoton | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest | Marime | 0.54 kb |
#include <cstdio>
using namespace std;
int a[100005], w, vmin, n;
int main()
{
freopen("twoton.in", "r", stdin);
freopen("twoton.out", "w", stdout);
scanf("%d", &n);
for(int i = 0; i < n; i ++)
scanf("%d", &a[i]);
w = 1;
vmin = a[n - 1];
for(int i = n - 2; i >= 0; i --)
{
if(a[i] < vmin)
w = w + 1;
else
w = 2 * w + 1;
w = w % 19997;
if(a[i] < vmin)
vmin = a[i];
}
printf("%d\n", w);
return 0;
}
