Submission #244482

#TimeUsernameProblemLanguageResultExecution timeMemory
244482dantoh000Calvinball championship (CEOI15_teams)C++14
100 / 100
206 ms760 KiB
#include <bits/stdc++.h> using namespace std; const int mod = 1000007; typedef long long ll; int n; int a[10005]; ll dp[2][10005]; int mx[10005]; ll ans = 0; int main(){ scanf("%d",&n); for (int i = 1; i <= n; i++){ scanf("%d",&a[i]); mx[i] = max(mx[i-1],a[i]); } for (int i = 1; i <= n; i++){ dp[0][i] = 1; } for (int i = 1; i < n; i++){ for (int j = 1; j <= n; j++){ dp[i&1][j] = j*dp[1-i&1][j] + dp[1-i&1][j+1]; dp[i&1][j] %= mod; } ans += (a[n-i]-1)*dp[i&1][mx[n-i-1]]; ans %= mod; } ans = (ans+a[n])%mod; printf("%lld",ans); }

Compilation message (stderr)

teams.cpp: In function 'int main()':
teams.cpp:21:32: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
             dp[i&1][j] = j*dp[1-i&1][j] + dp[1-i&1][j+1];
                               ~^~
teams.cpp:21:47: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
             dp[i&1][j] = j*dp[1-i&1][j] + dp[1-i&1][j+1];
                                              ~^~
teams.cpp:11:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
teams.cpp:13: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...