This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
#include "holiday.h"
const int MAX = 100; // max attractions
ll findMaxAttraction(int N, int start, int D, int attraction[]) {
vi a;
for (int i = 0; i < N; i++) {
a.pb(attraction[i]);
}
vi counts(MAX + 1, 0);
ll maximum = 0;
for (int i = 0; i < N; i++) { // get from [0, i], inclusive
ll total = 0;
// get D - i largest
ll rem = D - i;
counts[a[i]]++;
for (int j = MAX; j >= 0; j--) {
if (rem >= counts[j]) {
total += j * counts[j];
rem -= counts[j];
}
else {
total += j * rem;
rem = 0;
break;
}
}
maximum = max(maximum, total);
}
return maximum;
}
# | 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... |