Submission #548337

#TimeUsernameProblemLanguageResultExecution timeMemory
548337krit3379Calvinball championship (CEOI15_teams)C++17
70 / 100
7 ms340 KiB
#include<bits/stdc++.h> using namespace std; #define N 1005 long long a[N],p[2][N],ma[N],ans=1,mod=1e6+7; int main(){ int n,i,j,k,now=0,prev; scanf("%d",&n); for(i=1;i<=n;i++)scanf("%lld",&a[i]); for(i=1;i<=n;i++)p[now][i]=1,ma[i]=max(a[i],ma[i-1]); for(i=1;i<=n;i++){ prev=now; now=1-now; for(j=1;j<=n;j++){ p[now][j]=(j*p[prev][j]+p[prev][j+1])%mod; } ans+=(a[n-i+1]-1)*p[prev][ma[n-i]]; ans%=mod; } printf("%lld",ans); return 0; }

Compilation message (stderr)

teams.cpp: In function 'int main()':
teams.cpp:8:15: warning: unused variable 'k' [-Wunused-variable]
    8 |     int n,i,j,k,now=0,prev;
      |               ^
teams.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
teams.cpp:10:27: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     for(i=1;i<=n;i++)scanf("%lld",&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...