Submission #225522

# Submission time Handle Problem Language Result Execution time Memory
225522 2020-04-20T18:18:21 Z infinite_iq Schools (IZhO13_school) C++14
25 / 100
341 ms 19560 KB
#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
1 Correct 4 ms 256 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Incorrect 5 ms 384 KB Output isn't correct
5 Incorrect 5 ms 384 KB Output isn't correct
6 Incorrect 5 ms 384 KB Output isn't correct
7 Incorrect 9 ms 640 KB Output isn't correct
8 Correct 9 ms 768 KB Output is correct
9 Incorrect 9 ms 768 KB Output isn't correct
10 Incorrect 9 ms 768 KB Output isn't correct
11 Incorrect 9 ms 640 KB Output isn't correct
12 Incorrect 10 ms 768 KB Output isn't correct
13 Incorrect 43 ms 3568 KB Output isn't correct
14 Incorrect 84 ms 4596 KB Output isn't correct
15 Incorrect 160 ms 7416 KB Output isn't correct
16 Correct 206 ms 14184 KB Output is correct
17 Incorrect 257 ms 16104 KB Output isn't correct
18 Incorrect 273 ms 17000 KB Output isn't correct
19 Incorrect 292 ms 17768 KB Output isn't correct
20 Incorrect 341 ms 19560 KB Output isn't correct