#include "holiday.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N = 1e5;
int a[N];
ll findMaxAttraction(int n, int start, int d, int att[]) {
for(int i=0;i<n;i++){
a[i] = att[i];
}
ll ans = 0;
if(start==0){
priority_queue<ll> q;
multiset<ll> s;
ll sum = 0;
int mid = min(n, (d+1)/2);
if(d%2==0&&mid!=n)mid++;
for(int i=0;i<mid;i++){
s.insert(a[i]);
sum += a[i];
}ans = sum;
if(d%2==0&&mid!=n){
auto x = s.begin();sum -= *x;
s.erase(x);
}
for(int i=mid;i<min(d, n);i++){
auto f = s.begin();
sum -= *f;q.push(*f); s.erase(f);
ll mn = *s.begin();
q.push(a[i]);
ll mx = q.top();
if(mn < mx){
s.erase(s.find(mn));sum-=mn;
sum += mx;q.pop();
s.insert(mx);
}
ans = max(sum, ans);
}
}else {
cout << "I HAVE NO IDEA HOW TO SOLVE IT" << endl;
ans = (ll)892347238923847;
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
360 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
5732 KB |
Output is correct |
2 |
Correct |
31 ms |
5732 KB |
Output is correct |
3 |
Correct |
31 ms |
5732 KB |
Output is correct |
4 |
Correct |
30 ms |
5732 KB |
Output is correct |
5 |
Correct |
39 ms |
4704 KB |
Output is correct |
6 |
Correct |
11 ms |
1900 KB |
Output is correct |
7 |
Correct |
21 ms |
2924 KB |
Output is correct |
8 |
Correct |
25 ms |
3180 KB |
Output is correct |
9 |
Correct |
9 ms |
1388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
1132 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |