제출 #951966

#제출 시각아이디문제언어결과실행 시간메모리
951966GrandTiger1729Cake 3 (JOI19_cake3)C++17
0 / 100
1 ms600 KiB
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0)->sync_with_stdio(0); int n, K; cin >> n >> K; vector<pair<int, int>> a(n); for (int i = 0; i < n; i++) { cin >> a[i].second >> a[i].first; } sort(a.begin(), a.end()); long long ans = 0; for (int i = 0; i < n; i++) { long long cur = 0; priority_queue<int, vector<int>, greater<>> pq; for (int j = i + 1; j < n; j++) { while (pq.size() > K - 2) { cur -= pq.top(); pq.pop(); } if (pq.size() == K - 2) { ans = max(ans, cur + a[i].second + a[j].second - 2ll * (a[j].first - a[i].first)); } pq.push(a[j].second); cur += a[j].second; } } cout << ans << '\n'; return 0; }

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

cake3.cpp: In function 'int main()':
cake3.cpp:22:30: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int, std::vector<int>, std::greater<void> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   22 |             while (pq.size() > K - 2)
      |                    ~~~~~~~~~~^~~~~~~
cake3.cpp:27:27: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int, std::vector<int>, std::greater<void> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   27 |             if (pq.size() == K - 2)
      |                 ~~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...