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 "holiday.h"
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5;
typedef long long int ll;
long long int findMaxAttraction(int n, int start, int d, int a[]) {
ll ans = 0;
if(start==0){
vector<int>cnt(101,0);
d++;
for(int i=0;i<n;i++){
d--;
if(d<=0)break;
cnt[a[i]]++;
ll tot = 0;
ll sum = 0;
for(ll j=100;j>=0;j--){
tot+=cnt[j];
sum+=cnt[j] * j;
//if(tot <= d)ans = max(ans,sum);
if(tot-cnt[j]<=d && tot>=d){
ans = max(ans,sum - (tot-d) * j);
}
}
}
}
return ans;
}
# | 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... |