Submission #23122

#TimeUsernameProblemLanguageResultExecution timeMemory
23122model_codeCalvinball championship (CEOI15_teams)C11
100 / 100
139 ms1348 KiB
#include <stdio.h> #define MAXN 10000 #define MP 1000007 static long long num[2][MAXN]; static int seq[MAXN]; static int max_till[MAXN]; int main (void) { int i, k, n, old, before = 0; scanf ("%d", &n); for (i = 0; i < n; i++) { num[0][i] = 1; scanf ("%d", &seq[i]); } max_till[0] = 0; for (i = 1; i < n; i++) if (max_till[i - 1] < seq[i - 1]) max_till[i] = seq[i - 1]; else max_till[i] = max_till[i - 1]; old = 0; for (i = n - 1; i >= 0; i--) { int p = (num[old][max_till[i]] * (seq[i] - 1)) % MP; before = (before + p) % MP; for (k = 0; k < i; k++) num[1 - old][k] = (k * num[old][k] + num[old][k + 1]) % MP; old = 1 - old; } printf ("%d\n", before + 1); return 0; }

Compilation message (stderr)

teams.c: In function 'main':
teams.c:14:3: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
   scanf ("%d", &n);
   ^
teams.c:19:7: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
       scanf ("%d", &seq[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...