Submission #460904

#TimeUsernameProblemLanguageResultExecution timeMemory
460904kingfran1907Calvinball championship (CEOI15_teams)C++14
100 / 100
486 ms476 KiB
#include <bits/stdc++.h> #define X first #define Y second using namespace std; typedef long long llint; const int maxn = 1e4+2; const int base = 31337; const int mod = 1e6+7; const int inf = 0x3f3f3f3f; const int logo = 18; const int off = 1 << logo; const int treesiz = off << 1; int n; int niz[maxn]; int dp[2][maxn]; int pref[maxn]; int mul(int a, int b) { llint out = (llint) a * b; return out % mod; } int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", niz+i); } pref[0] = niz[0]; for (int i = 1; i < n; i++) pref[i] = max(pref[i - 1], niz[i]); int sol = 0; for (int i = 1; i <= n; i++) dp[0][i] = 1; int cnt = 1; for (int i = n - 1; i > 0; i--) { sol += mul(niz[i] - 1, dp[(n - i - 1) % 2][pref[i - 1]]); sol %= mod; for (int j = 1; j <= n; j++) dp[cnt][j] = (dp[1 - cnt][j + 1] + mul(j, dp[1 - cnt][j])) % mod; cnt = 1 - cnt; } printf("%d\n", sol + 1); return 0; }

Compilation message (stderr)

teams.cpp: In function 'int main()':
teams.cpp:27:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   27 |  scanf("%d", &n);
      |  ~~~~~^~~~~~~~~~
teams.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |   scanf("%d", niz+i);
      |   ~~~~~^~~~~~~~~~~~~
#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...