제출 #1033095

#제출 시각아이디문제언어결과실행 시간메모리
1033095c2zi6휴가 (IOI14_holiday)C++14
47 / 100
5005 ms2252 KiB
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(a) (a).begin(), (a).end() #define replr(i, a, b) for (int i = int(a); i <= int(b); ++i) #define reprl(i, a, b) for (int i = int(a); i >= int(b); --i) #define rep(i, n) for (int i = 0; i < int(n); ++i) #define mkp(a, b) make_pair(a, b) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<VPI> VVPI; typedef pair<ll, ll> PLL; typedef vector<ll> VL; typedef vector<PLL> VPL; typedef vector<VL> VVL; typedef vector<VVL> VVVL; typedef vector<VPL> VVPL; template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;} template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;} #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #include "holiday.h" ll findMaxAttraction(int n, int start, int d, int attraction[]) { VI a; rep(i, n) a.pb(attraction[i]); if (start == 0) { ll ans = 0; priority_queue<int> pq; ll cur = 0; rep(i, min(d, n)) { pq.push(-a[i]); cur += a[i]; while (pq.size() > d-i) { cur += pq.top(); pq.pop(); } setmax(ans, cur); } return ans; } else { ll ans = 0; int D = d; reprl(s, start, 0) { int d = D - (start - s); priority_queue<int> pq; ll cur = 0; for (int i = 0; i < d && s + i < n; i++) { // i = how many steps are spended on moving pq.push(-a[s + i]); cur += a[s + i]; while (pq.size() > d-i) { cur += pq.top(); pq.pop(); } setmax(ans, cur); } } replr(s, start, n-1) { int d = D - (s - start); priority_queue<int> pq; ll cur = 0; for (int i = 0; i < d && s - i >= 0; i++) { // i = how many steps are spended on moving pq.push(-a[s - i]); cur += a[s - i]; while (pq.size() > d-i) { cur += pq.top(); pq.pop(); } setmax(ans, cur); } } return ans; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

holiday.cpp: In function 'll findMaxAttraction(int, int, int, int*)':
holiday.cpp:44:30: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |             while (pq.size() > d-i) {
      |                    ~~~~~~~~~~^~~~~
holiday.cpp:62:34: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   62 |                 while (pq.size() > d-i) {
      |                        ~~~~~~~~~~^~~~~
holiday.cpp:77:34: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   77 |                 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...