Submission #244441

# Submission time Handle Problem Language Result Execution time Memory
244441 2020-07-04T05:57:50 Z dwsc Calvinball championship (CEOI15_teams) C++14
80 / 100
1000 ms 640 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1e6+7;
int memo[2][10010][2];
int arr[10010];
int n;
main(){
    cin >> n;
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        arr[i] = x;
    }
    for (int i = 0; i <= n; i++) memo[n%2][i][0] = memo[n%2][i][1] = 1;
    for (int i = n-1; i >= 0; i--){
        for (int j = 0; j <= i; j++){
            int curnum = arr[i];
            int ans = ((curnum-1)*memo[1-i%2][j][0])%MOD;
            ans += memo[1-i%2][max(j,curnum)][1];
            memo[i%2][j][1] = ans%MOD;
            int ans2 = (j*memo[1-i%2][j][0])%MOD + memo[1-i%2][j+1][0];
            memo[i%2][j][0] = ans2%MOD;
        }
    }
    cout << memo[0][0][1];
}

Compilation message

teams.cpp:8:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# 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
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 256 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 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 9 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 16 ms 384 KB Output is correct
2 Correct 17 ms 416 KB Output is correct
3 Correct 17 ms 416 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 640 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Correct 311 ms 560 KB Output is correct
2 Correct 299 ms 512 KB Output is correct
3 Correct 315 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 640 KB Time limit exceeded
2 Halted 0 ms 0 KB -