Submission #457824

#TimeUsernameProblemLanguageResultExecution timeMemory
457824vanicCalvinball championship (CEOI15_teams)C++14
100 / 100
972 ms472 KiB
#include <iostream> #include <cstdio> #include <cmath> #include <algorithm> using namespace std; typedef long long ll; const int maxn=1e4+5, mod=1e6+7, Log=20; int n; int dp[2][maxn]; inline int sum(int a, int b){ if(a+b>=mod){ return a+b-mod; } if(a+b<0){ return a+b+mod; } return a+b; } inline int mul(int a, int b){ return (ll)a*b%mod; } int a[maxn]; int pref[maxn]; int main(){ scanf("%d", &n); for(int i=0; i<n; i++){ scanf("%d", a+i); } int sol=1; bool tren=0; for(int i=0; i<maxn; i++){ dp[1][i]=1; } pref[0]=1; for(int i=0; i<n; i++){ pref[i+1]=max(pref[i], a[i]); } for(int i=n-1; i>-1; i--){ sol=sum(sol, mul(a[i]-1, dp[tren^1][pref[i]])); for(int j=0; j<maxn-1; j++){ dp[tren][j]=sum(mul(j, dp[tren^1][j]), dp[tren^1][j+1]); } tren^=1; } printf("%d\n", sol); return 0; }

Compilation message (stderr)

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