Submission #548336

# Submission time Handle Problem Language Result Execution time Memory
548336 2022-04-13T04:29:28 Z krit3379 Calvinball championship (CEOI15_teams) C++17
100 / 100
669 ms 640 KB
#include<bits/stdc++.h>
using namespace std;
#define N 10005

long long a[N],p[N],temp[N],ma[N],ans=1,mod=1e6+7;

int main(){
    int n,i,j,k;
    scanf("%d",&n);
    for(i=1;i<=n;i++)scanf("%lld",&a[i]);
    for(i=1;i<=n;i++)p[i]=1,ma[i]=max(a[i],ma[i-1]);
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++)temp[j]=p[j];
        for(j=1;j<=n;j++){
            p[j]=(j*temp[j]+temp[j+1])%mod;
        }
        ans=(ans+(a[n-i+1]-1)*temp[ma[n-i]])%mod;
    }
    printf("%lld",ans);
    return 0;
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:8:15: warning: unused variable 'k' [-Wunused-variable]
    8 |     int n,i,j,k;
      |               ^
teams.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
teams.cpp:10:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     for(i=1;i<=n;i++)scanf("%lld",&a[i]);
      |                      ~~~~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 212 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 2 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 340 KB Output is correct
2 Correct 7 ms 340 KB Output is correct
3 Correct 7 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 661 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 174 ms 460 KB Output is correct
2 Correct 165 ms 560 KB Output is correct
3 Correct 159 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 653 ms 596 KB Output is correct
2 Correct 658 ms 628 KB Output is correct
3 Correct 669 ms 640 KB Output is correct