Submission #1114542

#TimeUsernameProblemLanguageResultExecution timeMemory
1114542TsaganaSchools (IZhO13_school)C++14
75 / 100
88 ms3492 KiB
#include<bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie(); #define all(x) x.begin(), x.end() #define lnl long long #define pq priority_queue #define eb emplace_back #define lb lower_bound #define ub upper_bound #define pb push_back #define pp pop_back #define F first #define S second #define sp << ' ' << #define nl << '\n' using namespace std; bool cmp(pair<int, int> a, pair<int, int> b) {return (a.F - a.S < b.F - b.S ? 1 : 0);} void solve () { int n, m, s; cin >> n >> m >> s; vector<pair<int, int>> v(n); for (auto &i : v) cin >> i.F >> i.S; sort(all(v), cmp); int ans = 0; int sum = 0; pq<int> q; for (int i = 0; i < n; i++) { q.push(-v[i].S); sum += v[i].S; while (q.size() > s) {sum += q.top(); q.pop();} v[i].S = sum; } sum = 0; pq<int> ().swap(q); for (int i = n-1; i >= 0; i--) { q.push(-v[i].F); sum += v[i].F; while (q.size() > m) {sum += q.top(); q.pop();} ans = max(ans, sum + (i ? v[i-1].S : 0)); } cout << ans; } int main() {IOS solve(); return 0;}

Compilation message (stderr)

school.cpp: In function 'void solve()':
school.cpp:36:19: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |   while (q.size() > s) {sum += q.top(); q.pop();}
      |          ~~~~~~~~~^~~
school.cpp:46:19: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |   while (q.size() > m) {sum += q.top(); q.pop();}
      |          ~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...