Pagini recente » Cod sursa (job #2292497) | Cod sursa (job #2898130) | Cod sursa (job #70351) | Cod sursa (job #3272787) | Cod sursa (job #1935511)
#include <cstdio>
#include <algorithm>
using namespace std;
FILE *fin = fopen("twoton.in", "r"), *fout = fopen("twoton.out", "w");
const int mod = 19997;
const int nmax = 100000;
const int inf = (1 << 30);
int n;
int a[nmax + 1], creste[nmax + 1];
int cnt = 0;
int main()
{
fscanf(fin, "%d", &n);
for (int i = 0; i < n; ++ i) {
fscanf(fin, "%d", &a[ i ]);
}
int mn = inf;
for (int i = n - 1; i >= 0; -- i) {
if (a[ i ] < mn) {
creste[ i ] = creste[i + 1] + 1;
} else {
creste[ i ] = 2 * creste[i + 1] + 1;
}
creste[ i ] %= mod;
mn = min(mn, a[ i ]);
}
cnt = creste[ 0 ];
fprintf(fout, "%d\n", cnt);
fclose(fin);
fclose(fout);
}