Submission #86273

# Submission time Handle Problem Language Result Execution time Memory
86273 2018-11-25T21:21:52 Z rzbt Calvinball championship (CEOI15_teams) C++14
20 / 100
146 ms 900 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",(MOD+dp[1]-res)%MOD);

    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 3 ms 376 KB Output is correct
2 Incorrect 2 ms 508 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 516 KB Output is correct
2 Incorrect 2 ms 560 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 560 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 572 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 146 ms 900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 38 ms 900 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 141 ms 900 KB Output isn't correct
2 Halted 0 ms 0 KB -