Submission #169511

# Submission time Handle Problem Language Result Execution time Memory
169511 2019-12-20T18:26:40 Z muhammad_hokimiyon Schools (IZhO13_school) C++14
35 / 100
142 ms 12124 KB
#include <bits/stdc++.h>

#pragma GCC optimize("Ofast")

#define fi first
#define se second
#define ll long long

using namespace std;

const int N = 3e5 + 7;
const int mod = 1e9 + 7;

ll n,m,ss;
ll pr[N];
ll sf[N];
pair < ll , pair < ll , ll > > p[N];

void solve()
{
    cin >> n >> m >> ss;
    for( int i = 1; i <= n; i++ ){
        cin >> p[i].se.fi >> p[i].se.se;
        p[i].fi = p[i].se.fi - p[i].se.se;
    }
    sort( p + 1 , p + n + 1 );
    reverse( p + 1 , p + n + 1 );
    set < ll > s;
    for( int i = 1; i <= n; i++ ){
        pr[i] = pr[i - 1] + p[i].se.fi;
        s.insert(p[i].se.fi);
        if( i > m ){
            pr[i] -= *s.begin();
            s.erase(s.begin());
        }
    }
    s.clear();
    for( int i = n; i >= 1; i-- ){
        sf[i] = sf[i + 1] + p[i].se.se;
        s.insert(p[i].se.se);
        if( n - i + 1 > ss ){
            sf[i] -= *s.begin();
            s.erase(s.begin());
        }
    }
    ll ans = 0;
    for( int i = m; i <= n - ss; i++ ){
        ans = max( ans , pr[i] + sf[i + 1] );
    }
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int t = 1;//cin >> t;
    while( t-- ){
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Incorrect 4 ms 632 KB Output isn't correct
8 Correct 5 ms 760 KB Output is correct
9 Incorrect 5 ms 632 KB Output isn't correct
10 Incorrect 5 ms 760 KB Output isn't correct
11 Incorrect 5 ms 760 KB Output isn't correct
12 Incorrect 5 ms 760 KB Output isn't correct
13 Incorrect 25 ms 2680 KB Output isn't correct
14 Incorrect 45 ms 4088 KB Output isn't correct
15 Incorrect 75 ms 6776 KB Output isn't correct
16 Correct 124 ms 9008 KB Output is correct
17 Incorrect 106 ms 8996 KB Output isn't correct
18 Incorrect 115 ms 9748 KB Output isn't correct
19 Incorrect 125 ms 10616 KB Output isn't correct
20 Incorrect 142 ms 12124 KB Output isn't correct