Cod sursa(job #1709348)
Utilizator | Data | 28 mai 2016 11:54:08 | |
---|---|---|---|
Problema | Twoton | Scor | 100 |
Compilator | cpp | Status | done |
Runda | ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest | Marime | 0.5 kb |
#include <fstream>
using namespace std;
int n;
int a[1000024];
int main()
{
ifstream fin("twoton.in");
ofstream fout("twoton.out");
int i;
fin >> n;
for (i = 1; i <= n; i++)
fin >> a[i];
int minim, count;
minim = a[n]; count = 1;
for (i = n - 1; i >= 1; i--)
{
if (a[i] > minim)
count = (count * 2 + 1) % 19997;
else
{
minim = a[i];
count = (count + 1) % 19997;
}
}
fout << count%19997 << '\n';
fin.close();
fout.close();
return 0;
}