Submission #164411

#TimeUsernameProblemLanguageResultExecution timeMemory
164411tselmegkh학교 설립 (IZhO13_school)C++14
30 / 100
616 ms16448 KiB
#include<bits/stdc++.h> using namespace std; const int N = 3e5 + 5; int sum[N][2]; int main(){ int n, m, s; cin >> n >> m >> s; vector<pair<int, int>> v1, v2; for(int i = 0; i < n; i++){ int a, b; cin >> a >> b; v1.push_back({a - b, a}); v2.push_back({b - a, b}); } sort(v1.rbegin(), v1.rend()); sort(v2.rbegin(), v2.rend()); int tot = 0; multiset<int> ms; for(int i = 0; i < n; i++){ ms.insert(v1[i].second); tot += v1[i].second; if(ms.size() > m){ tot -= *ms.begin(); ms.erase(ms.begin()); } sum[i + 1][0] = tot; } tot = 0; ms.clear(); for(int i = 0; i < n; i++){ ms.insert(v2[i].second); tot += v2[i].second; if(ms.size() > s){ tot -= *ms.begin(); ms.erase(ms.begin()); } sum[i + 1][1] = tot; } int ans = 0; for(int i = m; i <= n - s; i++){ ans = max(ans, sum[i][0] + sum[n - i - 1][1]); } cout << ans << '\n'; }

Compilation message (stderr)

school.cpp: In function 'int main()':
school.cpp:26:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(ms.size() > m){
       ~~~~~~~~~~^~~
school.cpp:37:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(ms.size() > s){
       ~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...