Submission #90804

#TimeUsernameProblemLanguageResultExecution timeMemory
90804Aydarov03Schools (IZhO13_school)C++14
100 / 100
515 ms35160 KiB
#include <bits/stdc++.h> #define ll long long #define pii pair<ll,ll> #define fr first #define sc second using namespace std; vector < pii > v; main() { multiset < ll > rz; multiset < pii> v1 , v2; ll x , y; ll n , m , s , ans = 0; cin >> n >> m >> s; for(int i = 1; i <= n; i++) { cin >> x >> y; v.push_back( {x , y} ); } sort( v.rbegin() , v.rend() ); for(int i = 0; i < m; i++) { ans += v[i].fr; rz.insert( (v[i].fr - v[i].sc) ); } for(int i = m; i < n; i++) { v1.insert( v[i] ); v2.insert( {v[i].sc , v[i].fr} ); } for(int i = s; i >= 1; i--) { pii x = *v1.rbegin(); pii y = *v2.rbegin(); int raz = -*rz.begin(); if( x.fr + raz > y.fr ) { ans += (x.fr + raz); rz.erase( rz.begin() ); rz.insert( x.fr - x.sc ); v1.erase( v1.find( {x.fr , x.sc}) ); v2.erase( v2.find( {x.sc , x.fr} ) ); } else { ans += y.fr; v2.erase( v2.find( {y.fr , y.sc } ) ); v1.erase( v1.find( {y.sc , y.fr } ) ); } } cout << ans; }

Compilation message (stderr)

school.cpp:10:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...