Cod sursa(job #1709174)
Utilizator | Data | 28 mai 2016 11:09:35 | |
---|---|---|---|
Problema | Twoton | Scor | 100 |
Compilator | cpp | Status | done |
Runda | ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest | Marime | 0.57 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("twoton.in");
ofstream fout("twoton.out");
const int NMax = 1e5 + 5;
const int MOD = 19997;
int v[NMax];
int D[NMax];
int main(){
int n, t;
fin >> n;
for(int i = 1; i <= n; i++){
fin >> v[i];
}
D[n] = 1;
for(int i = n - 1; i > 0; i--){
if(v[i] < v[i + 1]){
D[i] = D[i + 1] + 1;
} else {
D[i] = 2 * D[i + 1] + 1;
v[i] = v[i + 1];
}
D[i] %= MOD;
}
fout << D[1];
return 0;
}