Submission #517019

#TimeUsernameProblemLanguageResultExecution timeMemory
517019amukkalirHoliday (IOI14_holiday)C++17
47 / 100
5030 ms2712 KiB
#include <bits/stdc++.h> #include "holiday.h" using namespace std; typedef long long ll; const int nax = 20; int n; int s, d; int cost (int l, int r) { return (r-l) + min(abs(s-l), abs(r-s)); } bool ok (int mask) { int l=n, r=0; for(int i=0; (1<<i)<=mask; i++) { if(mask & (1<<i)) { l = min(l, i); r = max(r, i); } } int travel = (r-l) + min(abs(s-l), abs(r-s)); return travel + __builtin_popcount(mask) <= d; } long long int findMaxAttraction(int N, int S, int D, int attraction[]) { n = N; s = S; d = D; ll ans = 0; priority_queue<ll, vector<ll>, greater<ll>> pq; ll sum = 0; for(int i=s;i<n;i++){ int rem = d - cost(s,i); if(rem <= 0) break; sum += attraction[i]; pq.push(attraction[i]); while(pq.size() > rem) { sum -= pq.top(); pq.pop(); } priority_queue<ll, vector<ll>, greater<ll>> q; q = pq; ll z = sum; for(int j=s-1; j>=0; j--) { rem = d - cost(j, i); if(rem <= 0) break; z += attraction[j]; q.push(attraction[j]); while(q.size() > rem) { z -= q.top(); q.pop(); } ans = max(ans, z); } ans = max(ans, sum); } return ans; } /* */

Compilation message (stderr)

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:44:25: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |         while(pq.size() > rem) {
      |               ~~~~~~~~~~^~~~~
holiday.cpp:58:28: warning: comparison of integer expressions of different signedness: 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   58 |             while(q.size() > rem) {
      |                   ~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...