Submission #40414

#TimeUsernameProblemLanguageResultExecution timeMemory
40414PajarajaCalvinball championship (CEOI15_teams)C++14
100 / 100
367 ms1436 KiB
#include <bits/stdc++.h> using namespace std; const int MOD=1000007; long long dp[10007],dpl[10007]; long long a[10007],parc[10007]; int main() { long long cur=0; int n; scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d",&a[i]); parc[0]=0; for(int i=1;i<=n;i++) parc[i]=fmax(parc[i-1],a[i]); for(int i=1;i<=n;i++) dp[i]=1; for(int j=n;j>=1;j--) { cur=(cur+dp[parc[j-1]]*(min(parc[j-1],a[j]-1)))%MOD; for(int i=parc[j-1]+1;i<a[j];i++) cur=(cur+dp[i])%MOD; for(int i=1;i<=n;i++) dpl[i]=dp[i]; for(int i=1;i<=n;i++) dp[i]=(i*dpl[i]+dpl[i+1])%MOD; } printf("%d",cur+1); }

Compilation message (stderr)

teams.cpp: In function 'int main()':
teams.cpp:11:40: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
  for(int i=1;i<=n;i++) scanf("%d",&a[i]);
                                        ^
teams.cpp:22:19: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
  printf("%d",cur+1);
                   ^
teams.cpp:10:16: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
teams.cpp:11:41: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;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...