Cod sursa(job #1709205)

Utilizator cojocarugabiReality cojocarugabi Data 28 mai 2016 11:16:40
Problema Twoton Scor 100
Compilator cpp Status done
Runda ONIS 2016 - Runda - 2 - ACM ICPC Romanian Programming Contest Marime 1.13 kb
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define db long double
# define scn(x) scanf("%I64d",&x)
# define scan(x) scanf("%d",&x)
# define print(x) printf("%d ",x)
# define prnt(x) printf("%I64d ",x);
# define eol printf("\n")
# define IOS ios_base :: sync_with_stdio(0)
# define pe "Possible"
# define ie "Impossible"
# define halt(...) {fo << (__VA_ARGS__) << '\n';exit(0);}
# define rep(n) for (int qwerty = 1;qwerty <= n;++qwerty)
# define pp(n) cerr << #n << " = " << n << '\n'
# define ppp(v) for (auto it : v) cerr << it << ' ';cerr << '\n'
const int mod = 1e9 + 7;
int s[1 << 20];
int dp[1 << 20];
const int MOD = 19997;
int main(void)
{
    int n;
    IOS;
    ifstream fi("twoton.in");
    ofstream fo("twoton.out");
    fi>>n;
    for (int i = 1;i <= n;++i) fi>>s[i];
    dp[n] = 1;
    for (int i = n - 1;i;--i)
    {
        if (s[i] < s[i+1]) dp[i] = (1 + dp[i+1]) % MOD;
        else dp[i] = (1 + dp[i+1] * 2) % MOD;
        s[i] = min(s[i],s[i+1]);
    }
    fo << dp[1] << '\n';
    return 0;
}