Submission #676393

#TimeUsernameProblemLanguageResultExecution timeMemory
676393vjudge1Schools (IZhO13_school)C++17
95 / 100
126 ms16528 KiB
#include <bits/stdc++.h> #define oo 1e18 #define ii pair<int,int> using namespace std; long long id[300010],a[300010],b[300010],x,y,n,f[300010],g[300010]; priority_queue<long long,vector<long long>,greater<long long> >pq; bool cmp(int i,int j) { return a[i] - b[i] < a[j] - b[j]; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n >> x >> y; for (int i = 1;i <= n;i++) { cin >> a[i] >> b[i]; } for (int i = 1;i <= n;i++) { id[i] = i; } sort(id + 1,id + n + 1,cmp); for (int i = 1;i <= n;i++) { f[i] = f[i - 1] + b[id[i]]; pq.push(b[id[i]]); if (pq.size() > y) { f[i] -= pq.top(); pq.pop(); } } while (pq.size() > 0) { pq.pop(); } for (int i = n;i >= 1;i--) { g[i] = g[i + 1] + a[id[i]]; pq.push(a[id[i]]); if (pq.size() > x) { g[i] -= pq.top(); pq.pop(); } } long long res = 0; for (int i = 1;i <= n;i++) { if ((i >= y) && (n - i >= x)) { res = max(res,f[i] + g[i + 1]); } } cout << res; return 0; }

Compilation message (stderr)

school.cpp: In function 'int main()':
school.cpp:29:23: 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]
   29 |         if (pq.size() > y)
      |             ~~~~~~~~~~^~~
school.cpp:43:23: 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]
   43 |         if (pq.size() > x)
      |             ~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...