Cod sursa(job #1709290)

Utilizator TeamFIIGUAIC Parjoala TeamFIIG Data 28 mai 2016 11:40:40
Problema Twoton Scor 0
Compilator cpp Status done
Runda ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest Marime 0.73 kb
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int n;
int a[1000024], b[1000024];
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()
{
	FILE *fin = fopen("twoton.in", "r");
	FILE *fout = fopen("twoton.out", "w");
	fscanf(fin, "%d", &n);
	for (int i = 0; i < n; ++i) 
		fscanf(fin, "%d", &a[i]);
	int i;
	b[n - 1] = 1;
	for (i = n - 2; i >= 0; i--)
	{
		if (a[i] >= a[i + 1])
		{
			b[i] = 1 + b[i + 1] + b[i + 1];
			a[i] = a[i + 1];
		}
		else b[i] = 1 + b[i + 1];


	}
	fprintf(fout, "%d\n", b[0]);
	
	fclose(fin);
	fclose(fout);
}