Submission #476794

#TimeUsernameProblemLanguageResultExecution timeMemory
476794ntabc05101Calvinball championship (CEOI15_teams)C++17
100 / 100
629 ms588 KiB
#include<bits/stdc++.h> using namespace std; #define taskname "" const int mxN = 10000; const int mod = 1e6 + 7; long long dp[2][mxN + 1]; #define dp(x) dp[(x) & 1] int a[mxN + 1], mx[mxN + 1]; int main() { if (fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } else { if (fopen(taskname".in", "r")) { freopen(taskname".in", "r", stdin); freopen(taskname".out", "w", stdout); } } cin.tie(0)->sync_with_stdio(0); int n; cin >> n; for (int i = 1; i <= n; i++) { cin >> a[i]; mx[i] = max(mx[i - 1], a[i]); } for (int i = 1; i <= n; i++) { dp(0)[i] = 1; } long long res = 1; for (int i = n - 1; i; i--) { for (int j = 1; j <= n; j++) { (dp(n - i)[j] = 1ll * j * dp(n - i - 1)[j]) %= mod; (dp(n - i)[j] += dp(n - i - 1)[j + 1]) %= mod; } for (int j = a[i] - 1; j; j--) { (res += dp(n - i)[max(mx[i - 1], j)]) %= mod; } } (res += a[n] - 1) %= mod; cout << res << "\n"; return 0; }

Compilation message (stderr)

teams.cpp: In function 'int main()':
teams.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen(taskname".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
teams.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     freopen(taskname".out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
teams.cpp:20:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |       freopen(taskname".in", "r", stdin);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
teams.cpp:21:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |       freopen(taskname".out", "w", stdout);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...