Submission #86271

# Submission time Handle Problem Language Result Execution time Memory
86271 2018-11-25T21:20:41 Z rzbt Calvinball championship (CEOI15_teams) C++14
20 / 100
151 ms 984 KB
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define MAXN 10005
typedef long long ll;


using namespace std;

const ll MOD = 1e6+7;
ll res;

ll n,niz[MAXN];
ll dp[MAXN],pdp[MAXN],pmax[MAXN],suma[MAXN];

int main()
{
    scanf("%lld", &n);
    for(int i=1;i<=n;i++)scanf("%lld",niz+i);
    for(int i=1;i<=n;i++){
        pdp[i]=1;
        pmax[i]=max(pmax[i-1],niz[i]);
    }

    for(int i=1;i<n;i++){
        for(int j=n-i;j>=1;j--){
            dp[j]=(j*pdp[j]+pdp[j+1])%MOD;
            //suma[j]=(suma[j+1]+dp[j])%MOD;
            //printf("   %d    %lld %lld\n",j,dp[j],suma[j]);
        }


        res+=pdp[pmax[n-i+1]+1]+(pmax[n-i+1]-niz[n-i+1])*pdp[pmax[n-i+1]];res%=MOD;
        for(int j=1;j<=n-i;j++)pdp[j]=dp[j];
        pdp[n-i+1]=0;
        //printf("%lld\n",res);

    }

    printf("%lld",dp[1]-res);

    return 0;
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld", &n);
     ~~~~~^~~~~~~~~~~~
teams.cpp:22:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=n;i++)scanf("%lld",niz+i);
                          ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 464 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 464 KB Output is correct
2 Incorrect 2 ms 520 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 524 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 576 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 580 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 147 ms 968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 968 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 151 ms 984 KB Output isn't correct
2 Halted 0 ms 0 KB -