답안 #244440

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
244440 2020-07-04T05:57:20 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 <= n; 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(){
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 256 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 256 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 384 KB Output is correct
2 Correct 10 ms 384 KB Output is correct
3 Correct 10 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 384 KB Output is correct
2 Correct 28 ms 384 KB Output is correct
3 Correct 29 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1097 ms 640 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Correct 595 ms 632 KB Output is correct
2 Correct 589 ms 632 KB Output is correct
3 Correct 620 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1097 ms 640 KB Time limit exceeded
2 Halted 0 ms 0 KB -