Cod sursa(job #1709872)

Utilizator Echipa_PietrelorMancam pietre Echipa_Pietrelor Data 28 mai 2016 14:14:30
Problema Twoton Scor 0
Compilator cpp Status done
Runda ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest Marime 1.06 kb
#include <stdio.h>
#include <fstream>

using namespace std;

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

ifstream in("twoton.in");
  FILE *fout = fopen("twoton.out", "w");

  #define MaxChar 1000000
#define verf ( (++CharB==MaxChar) ? ( in.read(Buffer,MaxChar),CharB=0 ) : (1) )

long CharB = MaxChar - 1;
char Buffer[MaxChar];

void cit(int &a)
{
    bool ok = 0;
    for( ; !( (Buffer[ CharB ]>='0' && Buffer[ CharB ]<='9') || ( Buffer[ CharB ] == '-' ) ); verf )
        ;
    if ( Buffer[ CharB ] == '-' )
    {
        CharB++;
        ok=1;
    }
    for( a=0; (Buffer[ CharB ]>='0' && Buffer[ CharB ]<='9'); a*=10,a+=( Buffer[ CharB ]-'0'), verf )
        ;
    if(ok)
        a=-a;
}

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()
{
  cit(n);
  for (int i = 0; i < n; ++i) {
    cit(a[i]);
  }
  wtf(0);
  fprintf(fout, "%d\n", count);
  fclose(fout);
}