Submission #639716

# Submission time Handle Problem Language Result Execution time Memory
639716 2022-09-11T08:26:16 Z tabr Holiday (IOI14_holiday) C++17
24 / 100
5000 ms 4788 KB
#include <bits/stdc++.h>
using namespace std;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

long long findMaxAttraction(int n, int s, int d, int a[]) {
    long long res = (long long) -9e18;
    for (int dir = 0; dir < 2; dir++) {
        priority_queue<long long, vector<long long>, greater<long long>> pq;
        long long sum = 0;
        for (int i = s; i < n; i++) {
            pq.emplace(a[i]);
            sum += a[i];
            while (!pq.empty() && (int) pq.size() + (i - s) > d) {
                sum -= pq.top();
                pq.pop();
            }
            res = max(res, sum);
            auto pq2 = pq;
            auto sum2 = sum;
            for (int j = s - 1; j >= 0; j--) {
                pq.emplace(a[j]);
                sum += a[j];
                while (!pq.empty() && (int) pq.size() + (i - s) + (s - j) * 2 > d) {
                    sum -= pq.top();
                    pq.pop();
                }
                res = max(res, sum);
            }
            swap(pq, pq2);
            swap(sum, sum2);
        }
        reverse(a, a + n);
        s = n - 1 - s;
    }
    return res;
}

#ifdef tabr
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    return 0;
}
#endif
# Verdict Execution time Memory Grader output
1 Correct 0 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 0 ms 596 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5064 ms 4344 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 724 KB Output is correct
2 Correct 3 ms 724 KB Output is correct
3 Correct 3 ms 840 KB Output is correct
4 Correct 275 ms 764 KB Output is correct
5 Correct 184 ms 772 KB Output is correct
6 Correct 4 ms 724 KB Output is correct
7 Correct 16 ms 736 KB Output is correct
8 Correct 16 ms 692 KB Output is correct
9 Correct 16 ms 732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5061 ms 4788 KB Time limit exceeded
2 Halted 0 ms 0 KB -