# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
586572 | SeDunion | Holiday (IOI14_holiday) | C++17 | 0 ms | 0 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"holiday.h"
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;
int cnt[111];
ll findMaxAttraction(int n, int start, int d, int attraction[]) {
ll ans = 0;
for (int i = 0 ; i < n ; ++ i) {
cnt[attraction[i]]++;
int x = d - i;
ll cur = 0;
for (int y = 100 ; y >= 0 ; -- y) {
int q = min(cnt[y], x);
x -= q;#include"holiday.h"
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
using namespace std;
using ll = long long;
const int N = 222;
const int D = 2*N + N/2;
ll sum = 0;
multiset<ll>st;
ll findMaxAttraction(int n, int start, int d, int attraction[]) {
ll ans = 0;
for (int _ = 0 ; _ < 2 ; ++ _) {
for (int i = start ; i < n ; ++ i) {
int x = d - (i - start);
st.clear();
sum = 0;
for (int j = i ; j >= 0 ; -- j) {
sum += attraction[j];
st.insert(attraction[j]);
int y = x - (i - j);
if (y < 0) break;
while ((int)st.size() > y) {
sum -= *st.begin();
st.erase(st.begin());
}
ans = max(ans, sum);
}
}
reverse(attraction, attraction + n);
start = n - start - 1;
}
return ans;
}
cur += q * y;
}
ans = max(ans, cur);
}
return ans;
}