Submission #44748

#TimeUsernameProblemLanguageResultExecution timeMemory
44748RayaBurong25_1Calvinball championship (CEOI15_teams)C++17
100 / 100
402 ms944 KiB
#include <stdio.h> #define MOD 1000007LL int n; int a[10005]; int mx[10005]; long long dp[10005]; long long max(long long a, long long b) { return (a > b)?a:b; } int main() { scanf("%d", &n); int i, j; for (i = 0; i < n; i++) scanf("%d", &a[i]); long long ans = 1; // int mx = 0; for (i = 0; i < n; i++) { if (i == 0) mx[i] = a[i]; else mx[i] = max(mx[i - 1], a[i]); } for (i = 0; i < n - 1; i++) { for (j = 1; j <= n - i; j++) { if (i == 0) dp[j] = 1LL; else dp[j] = (1LL*j*dp[j] + dp[j + 1])%MOD; // if (j <= 2*n - i) // printf("%d ", dp[j]); } // printf("\n"); for (j = 1; j < a[n - 1 - i]; j++) ans = (ans + dp[max(mx[n - 2 - i], j)])%MOD; } // for (i = n - 1; i > 0; i--) // { // for (j = 1; j < a[i]; j++) // ans = (ans + dp[max(mx[i - 1], j)])%MOD; // // mx = max(mx, a[i]); // } printf("%lld", ans); }

Compilation message (stderr)

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