Submission #130506

#TimeUsernameProblemLanguageResultExecution timeMemory
130506m3r8Calvinball championship (CEOI15_teams)C++14
100 / 100
353 ms672 KiB
#include <stdio.h> #define MOD 1000007 #define ll long long ll anzN[10010]; ll mx; int num[10010]; void updateS(){ for(int i = mx;i>1;i--){ if(anzN[i]){ anzN[i+1] += anzN[i]; anzN[i] = anzN[i] * (i-1); anzN[i] %= MOD; mx = mx < i+1 ? i+1:mx; }; }; }; int used[10010]; int getA(int idx){ for(int i = 0;i<idx;i++){ used[i] = 0; }; int erg = 0; for(int i = 0;i<idx;i++){ if(!used[num[i]]){ used[num[i]] = 1; erg++; }; }; return erg+1; }; ll sum(){ ll erg = 0; for(int i = 2;i<=mx;i++){ erg += anzN[i] * i; erg %= MOD; }; return erg; }; int main(void){ int n; scanf("%d",&n); for(int i = 0;i<n;i++){ scanf("%d",&num[i]); }; for(int i = 1;i<n-1;i++){ updateS(); int a = getA(i); //printf("%d\n",a); anzN[a] += num[i]-1; mx = mx < a ? a:mx; }; printf("%lld\n",(sum()+num[n-1])%MOD); };

Compilation message (stderr)

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