# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
130506 | m3r8 | Calvinball championship (CEOI15_teams) | C++14 | 353 ms | 672 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |