Submission #1121841

#TimeUsernameProblemLanguageResultExecution timeMemory
1121841coolboy19521Calvinball championship (CEOI15_teams)C++17
70 / 100
132 ms65536 KiB
#include"bits/stdc++.h" using namespace std; const int md = 1000007; const int mxN = 10004; int dp[mxN][mxN]; int a[mxN]; main() { int N; cin >> N; for (int i = 1; i <= N; i ++) { cin >> a[i]; } for (int i = 1; i <= N + 1; i ++) { assert(N + 1 < mxN && i < mxN); dp[N + 1][i] = 1; } for (int i = N; 1 <= i; i --) { for (int j = i; 1 <= j; j --) { assert(j + 1 < mxN && i + 1 < mxN); dp[i][j] = (dp[i][j] + 1ll * dp[i + 1][j] * j % md) % md; dp[i][j] = (dp[i][j] + 1ll * dp[i + 1][j + 1]) % md; } } int ans = 0; int mx = 0; for (int i = 1; i <= N; i ++) { mx = max(mx, a[i - 1]); for (int j = a[i] - 1; 1 <= j; j --) { assert(max(mx, j) < mxN && i + 1 < mxN); ans = (0ll + ans + dp[i + 1][max(mx, j)]) % md; } } cout << (ans + 1ll) % md << endl; }

Compilation message (stderr)

teams.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...