# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
753011 | 2023-06-04T12:52:14 Z | Ronin13 | Calvinball championship (CEOI15_teams) | C++14 | 1000 ms | 976 KB |
#include <bits/stdc++.h> #define ll long long #define f first #define s second #define pll pair<ll,ll> #define pb push_back #define epb emplace_back #define ull unsigned ll #define pii pair<int,int> using namespace std; const int nmax = 10001; ll mod = 1e6 + 7; ll dp[nmax]; ll DP[nmax]; ll c[nmax]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; //fil(2); int a[n + 1]; for(int i = 1; i <= n; i++){ cin >> a[i]; } dp[0] = 1; DP[0] = 1; c[0] = 1; for(int i = 1; i <= n ;i++){ for(int j = i; j >= 1 ;j--){ dp[j] = (ll)dp[j - 1] + (ll)dp[j] * (ll)j; DP[i] += dp[j]; DP[i] %= mod; dp[j] %= mod; } dp[0] = 0; // cout << DP[i] << ' '; } set <int> st; ll po[n + 1]; ll ans = 1; ll val[n + 1]; val[1] = 1; st.insert(a[1]); for(int i = 2; i <= n; i++){ st.insert(a[i]); val[i] = st.size(); } for(int i = n ;i >= 2; --i){ c[n - i] = 1; for(int j = n - i - 1; j >= 1 ;j--) c[j] += c[j - 1], c[j] %= mod; if(i != 1){ ll P = 1; ll res = 0; for(int x = n - i; x >= 0; x--){ res += c[x] * DP[x] * P; res %= mod; P *= val[i - 1]; P %= mod; } res *= (ll)(a[i] - 1); res %= mod; ans += res; ans %= mod; } } cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 328 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | 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 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | 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 |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 340 KB | Output is correct |
2 | Correct | 5 ms | 340 KB | Output is correct |
3 | Correct | 5 ms | 368 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 16 ms | 340 KB | Output is correct |
2 | Correct | 17 ms | 372 KB | Output is correct |
3 | Correct | 19 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1059 ms | 976 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 455 ms | 516 KB | Output is correct |
2 | Correct | 424 ms | 604 KB | Output is correct |
3 | Correct | 433 ms | 704 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1051 ms | 620 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |