Submission #614946

#TimeUsernameProblemLanguageResultExecution timeMemory
614946cheissmartHoliday (IOI14_holiday)C++14
23 / 100
16 ms2196 KiB
#include"holiday.h"
#include <bits/stdc++.h>
#define F first
#define S second
#define V vector
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

ll findMaxAttraction(int n, int s, int d, int a[]) {
    if(s == 0) {
        int cost = 0;
        ll sum = 0, ans = 0;
        priority_queue<int, vi, greater<int>> pq;
        for(int i = 0; i < n; i++) {
            pq.push(a[i]);
            sum += a[i];
            while(SZ(pq) + cost > d) {
                sum -= pq.top();
                pq.pop();
            }
            ans = max(ans, sum);
            cost++;
        }
        return ans;
    }
}

Compilation message (stderr)

holiday.cpp: In function 'll findMaxAttraction(int, int, int, int*)':
holiday.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
   37 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...