Cod sursa(job #1709029)

Utilizator TeamFIIBUAIC NoReturnValue TeamFIIB Data 28 mai 2016 10:38:08
Problema Twoton Scor 100
Compilator cpp Status done
Runda ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest Marime 0.73 kb
#include <iostream>
#include<vector>
#include<fstream>
#include<utility>

using namespace std;

int n;
int a[2000024];
int count = 0;

int wtf (int i) {
	count++;
	if (count >= 19997) {
		count -= 19997;
	}
	
	if (i == n-1) {
	   return a[i];
    }
    if (a[i] < wtf(i+1))
 	   return a[i];
    else {
	   return wtf(i+1);
    }
}

int main() {

	ifstream cin("twoton.in");
	ofstream cout("twoton.out");

	cin>>n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	long long c = 1, ret = a[n-1];
	for (int i = n - 2; i >= 0; i--) {
		if (a[i] < ret) {
			c = c + 1;
			c %= 19997;
			ret = a[i];
		}
		else {
			c = 2 * c;
			c = c + 1;
			c %= 19997;
		}
	}

	cout << c << '\n';

	return 0;
}