//#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];
int dp[1005][1005], dp1[1005][1005];
void rec(int cur = 1, int len = 1) {
if (len == n) {
cnt++;
return;
for (int i = 1; i <= n; i++) {
if (a[i] != b[i])
return;
}
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;
}
}
main() {
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> a[i];
dp[n][i] = i;
dp1[n][i] = 1;
}
for (int i = n - 1; i >= 1; i--) {
for (int j = n; j >= 1; j--) {
res[j] = (res[j + 1] + dp[i + 1][j]) % mod;
}
for (int j = 1; j <= n; j++) {
dp[i][j] = ((dp[i + 1][j] * j) % mod + dp[i][j]) % mod;
dp[i][j] = (dp[i][j] + dp1[i + 1][j + 1]) % mod;
dp1[i][j] = (dp1[i][j] + dp[i + 1][j + 1]) % mod;
// cout << dp[i][j] << " " << dp1[i][j] << "\n";
}
// cout << "\n";
}
// rec();
int ans = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j < a[i]; j++) {
ans = (ans + dp1[i][j]) % mod;
}
}
cout << (ans + 1) % mod;
return 0;
}
Compilation message
teams.cpp:38:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main() {
^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
384 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 |
Incorrect |
3 ms |
432 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
1280 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
1280 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
15 ms |
8220 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
36 ms |
16108 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |