답안 #546098

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
546098 2022-04-06T10:55:45 Z CPSC Calvinball championship (CEOI15_teams) C++14
70 / 100
99 ms 65536 KB
# include <bits/stdc++.h>
#define f first
#define s second
#define int long long
#define pb push_back
#define pii pair <int ,int>
using namespace std;
const int N = 3005, mod = 1e6 + 7;
int dp[N][N],a[N],n,mx,ans;
main() {
    std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>n;
    for (int i = 1; i <= n; i++) {
        cin>>a[i];
    }
    for (int i = 0; i <= n; i++) {
        dp[0][i] = 1;
    }
    for (int i = 1; i <= n; i++) {
        for (int mx = 1; mx <= n; mx++) {
            dp[i][mx] = dp[i - 1][mx]*mx+dp[i - 1][mx + 1];
            dp[i][mx] %= mod;
        }
    }
    mx = 0;
    for (int i = 1; i <= n; i++) {
        ans += ((a[i] - 1)*dp[n - i][mx])%mod; ans %= mod;
        mx = max(mx,a[i]);
    }cout<<(ans+1)%mod<<"\n";
}

Compilation message

teams.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 724 KB Output is correct
2 Correct 1 ms 724 KB Output is correct
3 Correct 1 ms 712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4308 KB Output is correct
2 Correct 3 ms 4300 KB Output is correct
3 Correct 3 ms 4308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 12136 KB Output is correct
2 Correct 7 ms 12200 KB Output is correct
3 Correct 9 ms 12116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 79 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 62 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 99 ms 65536 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -