Submission #244482

# Submission time Handle Problem Language Result Execution time Memory
244482 2020-07-04T06:59:47 Z dantoh000 Calvinball championship (CEOI15_teams) C++14
100 / 100
206 ms 760 KB
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000007;
typedef long long ll;
int n;
int a[10005];
ll dp[2][10005];
int mx[10005];
ll ans = 0;
int main(){
    scanf("%d",&n);
    for (int i = 1; i <= n; i++){
        scanf("%d",&a[i]);
        mx[i] = max(mx[i-1],a[i]);
    }
    for (int i = 1; i <= n; i++){
        dp[0][i] = 1;
    }
    for (int i = 1; i < n; i++){
        for (int j = 1; j <= n; j++){
            dp[i&1][j] = j*dp[1-i&1][j] + dp[1-i&1][j+1];
            dp[i&1][j] %= mod;
        }
        ans += (a[n-i]-1)*dp[i&1][mx[n-i-1]];
        ans %= mod;
    }
    ans = (ans+a[n])%mod;
    printf("%lld",ans);

}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:21:32: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
             dp[i&1][j] = j*dp[1-i&1][j] + dp[1-i&1][j+1];
                               ~^~
teams.cpp:21:47: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
             dp[i&1][j] = j*dp[1-i&1][j] + dp[1-i&1][j+1];
                                              ~^~
teams.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
teams.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&a[i]);
         ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 432 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 7 ms 384 KB Output is correct
3 Correct 7 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 198 ms 644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 67 ms 504 KB Output is correct
2 Correct 55 ms 504 KB Output is correct
3 Correct 54 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 202 ms 512 KB Output is correct
2 Correct 199 ms 512 KB Output is correct
3 Correct 206 ms 760 KB Output is correct