Cod sursa(job #1709074)

Utilizator lookingForAChallengeUBB Cociorva Popoveniuc Salajan lookingForAChallenge Data 28 mai 2016 10:48:08
Problema Twoton Scor 100
Compilator cpp Status done
Runda ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest Marime 0.91 kb
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

const int NMAX = 1000024;
const int MOD = 19997;

int N;
int A[NMAX + 5];
int countt = 0;

int wtf(int i) {
	countt++;
	if (countt >= 19997)
		countt -= 19997;

	if (i == N - 1)
		return A[i];

	if (A[i] < wtf(i + 1))
		return A[i];
	else
		return wtf(i + 1);
}

int main() {
	cin.sync_with_stdio(false);

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

	scanf("%d", &N);

	for (int i = 0; i < N; i++)
		scanf("%d", &A[i]);

	// wtf(0);

	int M = (1 << 30);
	int S = 0;
	for (int i = N - 1; i >= 0; i--) {
		if (A[i] < M) S = (S + 1) % MOD;
		else S = (S * 2 + 1) % MOD;
		M = min(M, A[i]);
	}

	printf("%d\n", S);
	// fprintf(stderr, "%d\n", countt);

	return 0;
}