Submission #673599

#TimeUsernameProblemLanguageResultExecution timeMemory
673599moday_morningSchools (IZhO13_school)C++17
100 / 100
131 ms10772 KiB
#include <bits/stdc++.h> #define fr first #define sc second #define int long long using namespace std; const int N = 300005; int v[N], v1[N]; pair <int, int> a[N]; void solve () { int n, x, y; cin >> n >> x >> y; for(int i = 1; i <= n; i++) { cin >> a[i].fr >> a[i].sc; } sort(a+1, a+n+1, [] (pair <int, int> a, pair <int, int> b) -> bool {return a.fr - a.sc > b.fr - b.sc;}); priority_queue<int, vector<int>, greater<int>> q; int sum = 0;; for (int i = 1; i <= n; i++) { sum += a[i].fr; q.push(a[i].fr); if(q.size() > x) { sum -= q.top(); q.pop(); } v[i] = sum; } while (!q.empty()) { q.pop(); sum = 0; } for (int i = n; i >= 1; i--) { sum += a[i].sc; q.push(a[i].sc); if (q.size() > y) { sum -= q.top(); q.pop(); } v1[i] = sum; } int mx = 0; for (int i = x; i <= n-y; i++) { mx = max(mx, v[i] + v1[i+1]); } cout << mx << "\n"; } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t = 1; // cin >> t; while (t--) { solve(); } }

Compilation message (stderr)

school.cpp: In function 'void solve()':
school.cpp:23:21: 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 'long long int' [-Wsign-compare]
   23 |         if(q.size() > x) {
      |            ~~~~~~~~~^~~
school.cpp:36:22: 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 'long long int' [-Wsign-compare]
   36 |         if (q.size() > y) {
      |             ~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...