Submission #156360

#TimeUsernameProblemLanguageResultExecution timeMemory
156360AkashiCalvinball championship (CEOI15_teams)C++14
100 / 100
288 ms632 KiB
#include <bits/stdc++.h> using namespace std; const int MOD = 1000007; int n; int a[10005], Max[10005]; int d[2][10005]; int main() { scanf("%d", &n); for(int i = 1; i <= n ; ++i) scanf("%d", &a[i]), Max[i] = max(Max[i - 1], a[i]); int l = 0, cnt = 1; for(int i = 1; i <= n ; ++i) d[0][i] = 1; for(int i = n; i >= 1 ; --i){ for(int j = 1; j <= a[i] - 1 ; ++j){ cnt += d[l][Max[i - 1]]; if(cnt >= MOD) cnt -= MOD; } l = 1 - l; for(int j = 1; j <= n ; ++j) d[l][j] = (1LL * d[1 - l][j] * j + d[1 - l][j + 1]) % MOD; } printf("%d", cnt); return 0; }

Compilation message (stderr)

teams.cpp: In function 'int main()':
teams.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
teams.cpp:14:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i]), Max[i] = max(Max[i - 1], a[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...