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>
using namespace std;
#define MAXN 100005
typedef long long lld;
static int N, S, T;
static int A[MAXN];
lld findMaxAttraction(int n, int start, int d, int arr[])
{
if (start) return 0;
N = n; S = start; T = d;
for (int i=1;i<=N;i++) A[i] = arr[i-1];
priority_queue <int> que;
int left = T;
lld ret = 0, sum = 0;
for (int i=1;i<=N;i++){
if (!left){
if (que.empty()) break;
int q = que.top(); que.pop();
sum += q;
left++;
}
sum += A[i];
que.push(-A[i]);
left--;
ret = max(ret, sum);
if (!left){
if (que.empty()) break;
int q = que.top(); que.pop();
sum += q;
left++;
}
left--;
}
return ret;
}
# | 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... |