Submission #584823

#TimeUsernameProblemLanguageResultExecution timeMemory
584823jack715Holiday (IOI14_holiday)C++14
23 / 100
21 ms1108 KiB
#include"holiday.h"
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pp pop_back
#define mp make_pair
#define bb back
#define ff first
#define ss second

using namespace std;

long long int findMaxAttraction(int n, int start, int d, int attraction[]) {
    ll ans = 0, D = d;
    vector<int> cnt(101, 0);
    for (int i = 0; i < min(d, n); i++) {
        cnt[attraction[i]]++;
        ll now = 0, c = D-i;
        for (int j = 100; j > 0; j--) {
            if (cnt[j] <= c) 
                now += j*cnt[j], c-=cnt[j];
            else 
                now += j*c, c = 0;
        }
        ans = max(ans, now);
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...