Pagini recente » Cod sursa (job #1753839) | Cod sursa (job #1360059) | Cod sursa (job #1562793) | Cod sursa (job #2771320) | Cod sursa (job #1709225)
#include <stdio.h>
#define mod 19997
int n;
int a[1000024];
int ret[1000024];
int cntp[1000024];
int count = 0;
int wtf(int i)
{
count++;
if (count >= 19997) {
count -= 19997;
}
printf("wtf=%d\n",i);
if (i == n - 1) {
return a[i];
}
if (a[i] < wtf(i + 1)) {
return a[i];
} else {
return wtf(i + 1);
}
}
int main()
{
FILE *fin = fopen("twoton.in", "r");
FILE *fout = fopen("twoton.out", "w");
fscanf(fin, "%d", &n);
for (int i = 0; i < n; ++i) {
fscanf(fin, "%d", &a[i]);
}
cntp[n-1] = 1;
ret[n-1] = a[n-1];
for(int i = n - 2; i >= 0; --i)
{
cntp[i] = 1 + cntp[i+1];
if(a[i] < ret[i+1])
{
ret[i] = a[i];
}
else
{
cntp[i] += cntp[i+1];
ret[i] = ret[i+1];
}
if (cntp[i] >= mod) {
cntp[i] -= mod;
}
}
fprintf(fout, "%d\n", cntp[0]);
fclose(fin);
fclose(fout);
}