Submission #230131

# Submission time Handle Problem Language Result Execution time Memory
230131 2020-05-08T16:46:50 Z DodgeBallMan Calvinball championship (CEOI15_teams) C++14
100 / 100
382 ms 760 KB
#include <bits/stdc++.h>
 
#define long long long
 
using namespace std;
 
const int N = 1e4+5;
const int M = 1e6+7;
 
int n, A[N], mx[N];
long dp[2][N];
 
int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", A + i);
        mx[i] = max(mx[i - 1], A[i]), dp[0][i] = 1;
    }
    long ans = 1ll * (A[n] - 1) * dp[0][mx[n - 1]];
    for(int i = 1; i <= n; i++) {
        int now = i & 1, pre = now ^ 1;
        for(int j = 0; j <= n; j++)
            dp[now][j] = (1ll * j * dp[pre][j] % M + dp[pre][j + 1]) % M;
        if(i < n)
            ans = (ans + (A[n - i] - 1) * dp[now][mx[n - i - 1]]) % M;
    }
    printf("%lld\n", ans + 1);
 
    return 0;
}

Compilation message

teams.cpp: In function 'int main()':
teams.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
teams.cpp:16: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 4 ms 384 KB Output is correct
2 Correct 5 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 384 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 4 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
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 256 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 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 8 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 365 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 94 ms 504 KB Output is correct
2 Correct 96 ms 632 KB Output is correct
3 Correct 100 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 382 ms 512 KB Output is correct
2 Correct 366 ms 512 KB Output is correct
3 Correct 360 ms 640 KB Output is correct