Nu aveti permisiuni pentru a descarca fisierul grader_test3.in
Cod sursa(job #1709828)
| Utilizator | Data | 28 mai 2016 14:03:34 | |
|---|---|---|---|
| Problema | Twoton | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest | Marime | 0.72 kb |
#include<iostream>
#include<fstream>
using namespace std;
ifstream f("twoton.in");
ofstream g("twoton.out");
int n;
int a[1000024];
int counts = 0;
int wtf(int i)
{
counts++;
if (counts >= 19997) {
counts -= 19997;
}
if (i == n - 1) {
return a[i];
}
if (a[i] < wtf(i + 1)) {
return a[i];
}
else {
return wtf(i + 1);
}
}
int main() {
f >> n;
for (int i = 0; i < n; ++i) {
f >> a[i];
}
int currentMin = a[n - 1];
int result = 0;
for (int i = n - 1; i >= 0; --i) {
if (currentMin > a[i]) {
result += 1;
result %= 19997;
currentMin = a[i];
}
else {
result = 2 * result + 1;
result %= 19997;
}
}
g << result << endl;
f.close();
g.close();
}