답안 #99745

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
99745 2019-03-06T16:07:33 Z HardNut Calvinball championship (CEOI15_teams) C++17
70 / 100
1000 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 = 2e5 + 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];
map<int, int> dp[10005];

void rec(int cur = 1, int len = 1) {
    if (len == n) {
        cnt++;
        for (int i = 1; i <= n; i++) {
            if (a[i] != b[i])
                return;
        }
        cout << "CH ";
        cout << cnt % mod;
        exit(0);
    }
    for (int i = 1; i <= cur + 1; i++) {
        b[len + 1] = i;
        rec(max(cur, i), len + 1);
        b[len + 1] = 0;
    }
}

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[0][i] = 1;
    }
    b[1] = 1;
    int ans = 0;
    int mx = 0;
    for (int i = 1; i < n; i++) {
        mx = max(mx, a[i]);
        for (int j = 1; j < a[i + 1]; j++) {
            ans = (ans + calc(n - i - 1, mx)) % mod;
        }
    }
    cout << (ans + 1) % mod;
    return 0;
}
/**
5
1 2 1 1 1
*/

Compilation message

teams.cpp:44: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 768 KB Output is correct
3 Correct 2 ms 768 KB Output is correct
4 Correct 3 ms 768 KB Output is correct
5 Correct 3 ms 768 KB Output is correct
6 Correct 3 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 768 KB Output is correct
2 Correct 2 ms 768 KB Output is correct
3 Correct 3 ms 896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 768 KB Output is correct
2 Correct 2 ms 768 KB Output is correct
3 Correct 2 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 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 71 ms 8616 KB Output is correct
2 Correct 63 ms 8696 KB Output is correct
3 Correct 77 ms 8696 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 454 ms 31988 KB Output is correct
2 Correct 432 ms 32068 KB Output is correct
3 Correct 449 ms 32144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1029 ms 66560 KB Time limit exceeded
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1006 ms 66560 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1059 ms 61824 KB Time limit exceeded
2 Halted 0 ms 0 KB -