# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
500769 | InternetPerson10 | Holiday (IOI14_holiday) | C++17 | 454 ms | 5404 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 <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
typedef long long ll;
long long int findMaxAttraction(int n, int start, int d, int attraction[]) {
ll best = 0;
// Try left
ll ans = 0;
multiset<int> s;
int g = d;
for(int i = start; i < n; i++) {
ans += attraction[i];
s.insert(attraction[i]);
while(g < s.size()) {
auto it = s.begin();
ans -= *(it);
s.erase(it);
}
g--;
best = max(ans, best);
if(g == 0) break;
}
multiset<int>().swap(s);
// Try right
g = d;
ans = 0;
for(int i = start; i >= 0; i--) {
ans += attraction[i];
s.insert(attraction[i]);
while(g < s.size()) {
auto it = s.begin();
ans -= *(it);
s.erase(it);
}
g--;
best = max(ans, best);
if(g == 0) break;
}
multiset<int>().swap(s);
cout << ans << '\n';
if(n <= 20) { // Subtask 1
}
else if(start == 0) { // Subtask 2
return best;
}
else if(n <= 3000) { // Subtask 3
for(int le = 0; le < start; le++) {
int l = start - le;
ans = 0;
set<int> s;
for(int i = le; i <= start; i++) s.insert(attraction[i]);
for(int rr = start+1; rr < n; rr++) {
int r = rr - start;
}
}
}
// Subtask 4
return 0;
}
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... |