답안 #99751

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
99751 2019-03-06T16:34:29 Z HardNut Calvinball championship (CEOI15_teams) C++17
100 / 100
379 ms 768 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];
vector <int> dp[2];

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

Compilation message

teams.cpp:20:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main() {
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 3 ms 256 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 10 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 379 ms 672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 98 ms 640 KB Output is correct
2 Correct 86 ms 512 KB Output is correct
3 Correct 107 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 356 ms 640 KB Output is correct
2 Correct 360 ms 700 KB Output is correct
3 Correct 373 ms 768 KB Output is correct