제출 #1121880

#제출 시각아이디문제언어결과실행 시간메모리
1121880coolboy19521Calvinball championship (CEOI15_teams)C++17
100 / 100
752 ms848 KiB
#include"bits/stdc++.h" using namespace std; using ll = long long; #define int ll const int md = 1000007; const int mxN = 10004; int dp[2][mxN]; int a[mxN]; int p[mxN]; int d[mxN]; main() { int N; cin >> N; for (int i = 1; i <= N; i ++) { cin >> a[i]; } for (int i = 1; i <= N; i ++) { p[i] = max(p[i - 1], a[i - 1]); } int ans = 0; dp[1][N + 1] = 1; for (int j = N; 1 <= j; j --) { for (int i = N; 1 <= i; i --) { if (j <= i) { dp[0][i] = (dp[0][i] + 1ll * dp[0][i + 1] * j % md) % md; dp[0][i] = (dp[0][i] + 1ll * dp[1][i + 1]) % md; if (j == p[i]) { d[i] = dp[0][i]; } if (j < a[i]) { if (j <= p[i]) { ans = (0ll + ans + d[i]); } else { ans = (0ll + ans + dp[0][i]); } } } } swap(dp[0], dp[1]); dp[1][N + 1] = 1; memset(dp[0], 0, sizeof(dp[0])); } cout << (ans + 1ll) % md << endl; }

컴파일 시 표준 에러 (stderr) 메시지

teams.cpp:16:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   16 | 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...