Submission #90772

# Submission time Handle Problem Language Result Execution time Memory
90772 2018-12-24T10:59:10 Z Aydarov03 Schools (IZhO13_school) C++14
30 / 100
457 ms 50932 KB
#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()
{
    set < ll > rz;
    set < pii> v1 , v2;

    int x , y;
    ll n , m , s , ans = 0;
    cin >> n >> m >> s;



    for(int i = 1; i <= n; i++)
    {
        scanf("%d%d" , &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

school.cpp:10:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
school.cpp: In function 'int main()':
school.cpp:23:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d" , &x , &y);
         ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Correct 2 ms 624 KB Output is correct
3 Correct 2 ms 624 KB Output is correct
4 Runtime error 2 ms 624 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Correct 2 ms 624 KB Output is correct
6 Correct 2 ms 624 KB Output is correct
7 Incorrect 5 ms 1188 KB Output isn't correct
8 Incorrect 4 ms 1188 KB Output isn't correct
9 Incorrect 4 ms 1188 KB Output isn't correct
10 Correct 4 ms 1188 KB Output is correct
11 Incorrect 6 ms 1348 KB Output isn't correct
12 Incorrect 6 ms 1404 KB Output isn't correct
13 Incorrect 24 ms 2928 KB Output isn't correct
14 Incorrect 118 ms 11024 KB Output isn't correct
15 Correct 254 ms 23092 KB Output is correct
16 Runtime error 457 ms 47740 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Incorrect 252 ms 47740 KB Output isn't correct
18 Incorrect 279 ms 47740 KB Output isn't correct
19 Incorrect 312 ms 47740 KB Output isn't correct
20 Incorrect 353 ms 50932 KB Output isn't correct