Submission #244494

#TimeUsernameProblemLanguageResultExecution timeMemory
244494shenxyCalvinball championship (CEOI15_teams)C++11
100 / 100
440 ms632 KiB
//happy birthday errorgorn #include <cstdio> #include <algorithm> using namespace std; const long long mod = 1000007; int main() { int n; scanf("%d", &n); int a[n], sa[n]; long long ans = 1; for (int i = 0; i < n; ++i) scanf("%d", &a[i]); sa[0] = a[0]; for (int i = 1; i < n; ++i) sa[i] = max(sa[i - 1], a[i]); long long dptable[2][n + 1]; fill_n(dptable[0], n + 1, 1); for (int i = 1; i <= n; ++i) { for (int j = 1; j < a[n - i]; ++j) ans = (ans + dptable[1 - (i & 1)][max(j, i == n ? 0 : sa[n - i - 1])]) % mod; for (int j = 0; j < n; ++j) dptable[i & 1][j] = (j * dptable[1 - (i & 1)][j] + dptable[1 - (i & 1)][j + 1]) % mod; dptable[i & 1][n] = n * dptable[1 - (i & 1)][n] % mod; } printf("%lld", ans); return 0; }

Compilation message (stderr)

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