답안 #244437

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
244437 2020-07-04T05:51:50 Z dwsc Calvinball championship (CEOI15_teams) C++14
70 / 100
36 ms 33020 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
int MOD = 1e6+7;
int memo[1010][1010][2];
int maxi[1010],arr[1010];
int n;
int dp(int pos,int largest,int ssf){
    if (pos == n) return !ssf;
    if (memo[pos][largest][ssf] != -1) return memo[pos][largest][ssf];
    if (ssf){
        int curnum = arr[pos];
        int ans = ((curnum-1)*dp(pos+1,largest,0))%MOD;
        ans += dp(pos+1,max(largest,curnum),1);
        return memo[pos][largest][ssf] = ans%MOD;
    }
    else{
        int ans = (largest*dp(pos+1,largest,0))%MOD + dp(pos+1,largest+1,0);
        return memo[pos][largest][ssf] = ans%MOD;
    }
}
main(){
    cin >> n;
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        arr[i] = x;
        if (i == 0) maxi[i] = x;
        else maxi[i] = max(maxi[i-1],x);
    }
    for (int i = 0; i < 1010; i++) for (int j = 0; j < 1010; j++) memo[i][j][0] = memo[i][j][1] =-1;
    cout << (dp(0,0,1)+1)%MOD;
}

Compilation message

teams.cpp:22:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 16256 KB Output is correct
2 Correct 12 ms 16256 KB Output is correct
3 Correct 12 ms 16256 KB Output is correct
4 Correct 12 ms 16256 KB Output is correct
5 Correct 12 ms 16256 KB Output is correct
6 Correct 12 ms 16256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 16256 KB Output is correct
2 Correct 13 ms 16256 KB Output is correct
3 Correct 12 ms 16256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 16256 KB Output is correct
2 Correct 12 ms 16256 KB Output is correct
3 Correct 12 ms 16128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 16256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 13 ms 16256 KB Output is correct
2 Correct 12 ms 16384 KB Output is correct
3 Correct 13 ms 16256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 16256 KB Output is correct
2 Correct 14 ms 16256 KB Output is correct
3 Correct 15 ms 16384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 16384 KB Output is correct
2 Correct 21 ms 16384 KB Output is correct
3 Correct 21 ms 16384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 34 ms 32924 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 35 ms 32896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 36 ms 33020 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -