| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 770763 | That_Salamander | 휴가 (IOI14_holiday) | C++17 | 30 ms | 6164 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 <bits/stdc++.h>
#define FOR(var,bound) for(int var = 0; var < bound; var++)
#define FORB(var,lb,ub) for (int var = lb; var < ub; var++)
#define FORR(var,bound) for(int var = bound-1; var >= 0; var--)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;
long long int findMaxAttraction(int n, int start, int d, int attraction[]) {
set<int> included;
set<int> excluded;
long long sum = 0;
long long res = 0;
for (int i = 0; i < min(d + 1, n); i++) {
excluded.insert(attraction[i]);
int canTake = d - i;
while (included.size() > canTake) {
auto it = included.begin();
excluded.insert(*it);
sum -= *it;
included.erase(it);
}
while (included.size() < canTake && excluded.size()) {
auto it = excluded.rbegin();
included.insert(*it);
sum += *it;
excluded.erase(*it);
}
res = max(sum, res);
}
return res;
}
#ifdef LOCAL_TEST
namespace hidden {
int attraction[1000000];
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, start, d;
cin >> n >> start >> d;
FOR(i, n) {
cin >> hidden::attraction[i];
}
cout << findMaxAttraction(n, start, d, hidden::attraction) << endl;
}
#endifCompilation 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... | ||||
