Cod sursa(job #1973968)

Utilizator otnielMercea Otniel otniel Data 26 aprilie 2017 15:35:26
Problema Twoton Scor 100
Compilator cpp Status done
Runda Arhiva ICPC Marime 0.68 kb
#include <stdio.h>

int n;
int a[1000024];
int count = 0;
int countv[1000024];
int wtf(int i)
{
  count++;
  if (count >= 19997) {
    count -= 19997;
  }
  if (i == n - 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]);
  }
  countv[n-1]=1;
  int minim=a[n-1];
  for(int i=n-2;i>=0;i--)
    if(a[i]>=minim)
    {
        countv[i]=2*countv[i+1]+1;
           if(countv[i]>=19997) countv[i]-=19997;

    }
    else{
        minim=a[i];
        countv[i]=(countv[i+1]+1);
        if(countv[i]>=19997) countv[i]-=19997;
    }
    fprintf(fout,"%d",countv[0]);
}