답안 #546100

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
546100 2022-04-06T11:01:22 Z CPSC Calvinball championship (CEOI15_teams) C++17
100 / 100
234 ms 664 KB
# include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define pii pair <int ,int>
#define int long long
using namespace std;
const int N = 10005, mod = 1e6 + 7;
int 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];
    }
    vector <int> dp(n + 1, 0), dp1(n + 1,0);
    for (int i = 0; i <= n; i++) {
        dp[i] = 1;
    }
    vector <int> pr(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        pr[i] = max(pr[i - 1], a[i]);
    }
    for (int i = n; i >= 1; i--) {
        ans += (a[i] - 1)*dp[pr[i - 1]]; ans %= mod;
        dp1 = dp;
        for (int mx = 1; mx <= n; mx++) {
            dp[mx] = dp1[mx]*mx + dp1[mx + 1]; dp[mx] %= mod;
        }
    }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 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 4 ms 340 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 4 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 234 ms 608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 468 KB Output is correct
2 Correct 55 ms 484 KB Output is correct
3 Correct 55 ms 488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 207 ms 656 KB Output is correct
2 Correct 222 ms 644 KB Output is correct
3 Correct 210 ms 664 KB Output is correct