Submission #775383

#TimeUsernameProblemLanguageResultExecution timeMemory
775383boris_mihovHoliday (IOI14_holiday)C++17
23 / 100
13 ms2636 KiB
#include "holiday.h"
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>
#include <queue>

typedef long long llong;
const int MAXN = 100000 + 10;
const int INF  = 1e9;

llong sum = 0;
std::priority_queue <llong> pq;

llong findMaxAttraction(int n, int start, int d, int a[])
{
    llong ans = 0;
    for (int i = 0 ; i < std::min(d, n) ; ++i)
    {
        sum += a[i];
        pq.push(-a[i]);
        while (pq.size() > d - i)
        {
            sum += pq.top();
            pq.pop();
        }

        ans = std::max(ans, sum);
    }

    return ans;
}

Compilation message (stderr)

holiday.cpp: In function 'llong findMaxAttraction(int, int, int, int*)':
holiday.cpp:23:26: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |         while (pq.size() > d - i)
      |                ~~~~~~~~~~^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...