Cod sursa(job #1709274)
Utilizator | Data | 28 mai 2016 11:35:24 | |
---|---|---|---|
Problema | Twoton | Scor | 0 |
Compilator | cpp | Status | done |
Runda | ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest | Marime | 0.44 kb |
#include <iostream>
#include <fstream>
using namespace std;
int v[1000100],n;
int main()
{
ifstream f ("twoton.in");
ofstream g ("twoton.out");
int i,c,x=0;
f>>n;
c=n%19997;
for(i=1;i<=n;i++)
f>>v[i];
for(i=n-1;i>=1;i--)
{
if(v[i]>=v[i+1])
{x=x+n-i;c=c+x;if(c>19997)c=c%19997;}
}
g<<c<<'\n';
f.close();
g.close();
return 0;
}