답안 #99749

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
99749 2019-03-06T16:13:16 Z HardNut Calvinball championship (CEOI15_teams) C++17
70 / 100
473 ms 66560 KB
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N = 1e4 + 5;
const ll INF = 1e18 + 5;
const ll mod = 1e6 + 7;
const int tx[] = {1, -1, 0, 0}, ty[] = {0, 0, 1, -1};
const ll bs = 31;

#define int ll

int n, a[N], b[N], cnt, res[N], mx[N];
unordered_map <int, int> dp[10005];

int calc(int id, int mx) {
    if (dp[id][mx])
       return dp[id][mx];
    return dp[id][mx] = (mx * calc(id - 1, mx) % mod + calc(id - 1, mx + 1)) % mod;
}

main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        dp[i].reserve(105);
        dp[0][i] = 1;
        mx[i] = max(mx[i - 1], a[i]);
    }
    int ans = 0;
    for (int i = n - 1; i >= 1; i--) {
        ans = (ans + (a[i + 1] - 1) * calc(n - i - 1, mx[i]) % mod) % mod;
    }
    cout << (ans + 1) % mod;
    return 0;
}
/**
5
1 2 1 1 1
*/

Compilation message

teams.cpp:26:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 896 KB Output is correct
2 Correct 3 ms 896 KB Output is correct
3 Correct 3 ms 896 KB Output is correct
4 Correct 3 ms 896 KB Output is correct
5 Correct 2 ms 896 KB Output is correct
6 Correct 3 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 896 KB Output is correct
2 Correct 3 ms 896 KB Output is correct
3 Correct 3 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 896 KB Output is correct
2 Correct 3 ms 896 KB Output is correct
3 Correct 3 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1152 KB Output is correct
2 Correct 4 ms 1152 KB Output is correct
3 Correct 4 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 6272 KB Output is correct
2 Correct 32 ms 6272 KB Output is correct
3 Correct 37 ms 6228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 198 ms 22264 KB Output is correct
2 Correct 194 ms 22188 KB Output is correct
3 Correct 171 ms 22136 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 473 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 450 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 444 ms 66560 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -