# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
225522 | infinite_iq | Schools (IZhO13_school) | C++14 | 341 ms | 19560 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 547
#define mid (l+r)/2
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef short int si;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll inf=1e18;
const ll mod=1e9+7;
const ld pai=acos(-1);
ll N , n , M , S ;
struct xxx{
ll mx , mn , m , s ;
} a[300009] ;
bool cmp ( xxx a , xxx b ) {
if ( a.mx == b.mx ) return a.mn > b.mn ;
return a.mx > b.mx ;
}
int main () {
cin >> n >> M >> S ;
N = M + S ;
for ( ll i = 0 ; i < n ; i ++ ) {
cin >> a[i].m >> a[i].s ;
a[i].mx = max ( a[i].m , a[i].s ) ;
a[i].mn = min ( a[i].m , a[i].s ) ;
}
sort ( a , a +n , cmp ) ;
vector < pair < ll , pll > > v;
for ( ll i = 0 ; i < N ; i ++ ) {
v.pb ( { a[i].m - a[i].s , { a[i].m , a[i].s } } ) ;
}
sort ( v.begin() , v.end() ) ;
ll ans = 0 ;
for ( ll i = N-1 ; i >= 0 ; i -- ) {
if ( M ) ans += v[i].se.fi , M -- ;
else ans += v[i].se.se ;
}
cout << ans << endl ;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |