Submission #34391

#TimeUsernameProblemLanguageResultExecution timeMemory
34391bnahmad15Calvinball championship (CEOI15_teams)C++14
100 / 100
476 ms2172 KiB
#include <bits/stdc++.h> using namespace std; const int N = 10010,MOD = 1000007; int n,ar[N],dp[2][N],mx[N],ans = 1; int main() { scanf("%d",&n); mx[0]=0; for(int i =0 ;i<n;i++){ scanf("%d",&ar[i]); if (i){ mx[i]=max(mx[i-1],ar[i-1]); } } for (int i = 0 ;i <= n+2 ; i++) dp[n&1][i]=1; for (int i = n-1;i >= 0 ;i--){ int m = mx[i]; for (int j =1 ;j < ar[i];j++){ m = max(m,j); ans += dp[(i+1) & 1][m]; ans %= MOD; } for (int j = 1; j<=i+1;j++){ dp[i&1][j]=(long long)dp[(i+1)&1][j]*j % MOD; dp[i&1][j] += dp[(i+1)&1][j+1]; dp[i&1][j]%= MOD; } } cout<<ans; return 0; }

Compilation message (stderr)

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