Submission #951970

#TimeUsernameProblemLanguageResultExecution timeMemory
951970GrandTiger1729Cake 3 (JOI19_cake3)C++17
0 / 100
3 ms408 KiB
#include <bits/stdc++.h> using namespace std; #define int long long 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; j < n; j++) { pq.push(a[j].second); cur += a[j].second; while (pq.size() > K) { cur -= pq.top(); pq.pop(); } if (pq.size() == K) { ans = max(ans, cur - 2ll * (a[j].first - a[i].first)); } } } cout << ans << '\n'; return 0; }

Compilation message (stderr)

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