Submission #285572

#TimeUsernameProblemLanguageResultExecution timeMemory
2855722qbingxuanHoliday (IOI14_holiday)C++14
47 / 100
5090 ms2348 KiB
#include"holiday.h" #include <bits/stdc++.h> #ifdef local #define debug(...) qqbx(#__VA_ARGS__, __VA_ARGS__) void qqbx(const char *s) {} template <typename H, typename ...T> void qqbx(const char *s, const H& h, T&& ...args) { for(; *s && *s != ','; ++s) if(*s != ' ') std::cerr << *s; std::cerr << " = " << h << (sizeof...(T) ? ", " : "\n"); if(sizeof...(T)) qqbx(++s, args...); } #define safe std::cerr<<__PRETTY_FUNCTION__<<" line "<<__LINE__<<" safe\n" #else #define debug(...) ((void)0) #define safe ((void)0) #endif // local #define pb emplace_back #define all(v) begin(v),end(v) using namespace std; using ll = long long; long long int findMaxAttraction(int n, int start, int d, int attraction[]) { if(start == 0) { priority_queue<int, vector<int>, greater<int>> pq; ll sum = 0; ll mx = 0; for(int i = 0; i < n; i++) { pq.push(attraction[i]); sum += attraction[i]; if(d - i > 0) { int k = d - i; while(pq.size() > k) sum -= pq.top(), pq.pop(); mx = max(mx, sum); } } return mx; } ll mx = 0; vector<int> v(attraction, attraction+n); for(int i = 0; i <= start; i++) { priority_queue<int, vector<int>, greater<int>> pq; ll sum = 0; for(int j = start-1; j >= i; j--) { pq.push(v[j]); sum += v[j]; } for(int j = start; j < n; j++) { pq.push(v[j]); sum += v[j]; int len = start - i + j - i; int k = d - len; if(d - len > 0) { while(int(pq.size()) > k) sum -= pq.top(), pq.pop(); mx = max(mx, sum); } } } debug(mx); reverse(all(v)); start = n-1-start; debug(start); for(int i = 0; i <= start; i++) { priority_queue<int, vector<int>, greater<int>> pq; ll sum = 0; for(int j = start-1; j >= i; j--) { pq.push(v[j]); sum += v[j]; } for(int j = start; j < n; j++) { pq.push(v[j]); sum += v[j]; int len = start - i + j - i; int k = d - len; if(d - len > 0) { while(int(pq.size()) > k) sum -= pq.top(), pq.pop(); mx = max(mx, sum); } } } return mx; }

Compilation message (stderr)

holiday.cpp: In function 'long long int findMaxAttraction(int, int, int, int*)':
holiday.cpp:31:33: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int, std::vector<int>, std::greater<int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   31 |                 while(pq.size() > k) sum -= pq.top(), pq.pop();
      |                       ~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...