Cod sursa(job #1709156)

Utilizator oldscotchUPB Old Scotch oldscotch Data 28 mai 2016 11:06:35
Problema Twoton Scor 100
Compilator cpp Status done
Runda ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest Marime 0.81 kb
#include <stdio.h>

int n;
int a[1000024];
int count = 0;
int globalCount =0;
struct cacat
{
    int x, y;
} ;
cacat wtf(int i)
{
    cacat rez;
    rez.x = 1;
    if (i == n - 1)
    {
        rez.y = a[i];
        return rez;
    }
    cacat rez2=wtf(i+1);
    rez.x += rez2.x;
    rez.x = rez.x % 19997;
    if (a[i] < rez2.y)
    {
        rez.y = a[i];
        return rez;
    }
    else
    {
         rez.x += rez2.x;
        rez.x = rez.x % 19997;
        rez.y = rez2.y;
        return rez;
    }
}

int main()
{
    FILE *fin = fopen("twoton.in", "r");
    freopen("twoton.out", "w", stdout);
    fscanf(fin, "%d", &n);
    for (int i = 0; i < n; ++i)
    {
        fscanf(fin, "%d", &a[i]);
    }
    cacat cv = wtf(0);
    printf("%d\n", cv.x );
    fclose(fin);
}