Cod sursa(job #1709474)

Utilizator UAIC_TheFormerOneUAIC TheFormerOne UAIC_TheFormerOne Data 28 mai 2016 12:28:40
Problema Twoton Scor 0
Compilator cpp Status done
Runda ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest Marime 0.58 kb
#include<fstream>
#include<cstring>
using namespace std;


int main()
{

	int n, i, j;
	ifstream fin("twoton.in");
	ofstream fout("twoton.out");

	int v[100002], a[100002] = { 0 };

	fin >> n;

	for (i = 1; i <= n; ++i)
		fin >> v[i];
	
	for (i = 0; i <= n + 1; ++i)
		a[i] = 1;
	
	int min = v[n];
	
	for (i = n-1; i > 0; --i)
	{
		if (v[i] < min) continue;
		else
		{
			for (j = i + 1; j <= n; ++j)
				a[i] = (a[i]* 2) % 19997;
			//min = v[i];
		}
	}
	int sum = 0;
	for (i = 1; i <= n; ++i)
		sum = (sum + a[i]) % 19997;
	fout << sum;
	return 0;
}