Cod sursa(job #1709111)

Utilizator UTCN_heapstrUTCN HeapStr UTCN_heapstr Data 28 mai 2016 10:56:29
Problema Twoton Scor 100
Compilator cpp Status done
Runda ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest Marime 0.83 kb
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>

using namespace std;

int main(){
	freopen("twoton.in", "r", stdin);
	freopen("twoton.out", "w", stdout);

	int n, a, b;
	int count = 0, pw = 1;
	vector<int> v;
	vector<int> m;

	scanf("%d", &n);
	v.resize(n);
	m.resize(n);

	for (int i = 0; i < n; i++) {
		scanf("%d", &v[i]);
	}

	m[n - 1] = v[n - 1];
	for (int i = n - 2; i >= 0; i--) {
		if (v[i] < m[i + 1]) {
			m[i] = v[i];
		}
		else {
			m[i] = m[i + 1];
		}
	}

	for (int i = 0; i < n-1; i++) {
		count = (count + pw) % 19997;
		if (v[i] > m[i + 1]) {
			pw = (pw * 2) % 19997;
		}
	}
	count = (count + pw) % 19997;

	printf("%d\n", count);

	return 0;
}