Submission #90762

# Submission time Handle Problem Language Result Execution time Memory
90762 2018-12-24T10:37:40 Z Aydarov03 Schools (IZhO13_school) C++14
5 / 100
503 ms 35316 KB
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define fr first
#define sc second
using namespace std;

vector < pii > v;
vector < pii > v1 , v2;

main()
{
    multiset < int > rz;
    multiset < pii> v1 , v2;

    int x , y;
    int 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.sc - x.fr ) );
            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 << endl;


}

Compilation message

school.cpp:11:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Correct 2 ms 380 KB Output is correct
3 Incorrect 2 ms 424 KB Output isn't correct
4 Incorrect 2 ms 440 KB Output isn't correct
5 Incorrect 2 ms 500 KB Output isn't correct
6 Incorrect 2 ms 576 KB Output isn't correct
7 Incorrect 7 ms 1188 KB Output isn't correct
8 Incorrect 5 ms 1188 KB Output isn't correct
9 Incorrect 6 ms 1188 KB Output isn't correct
10 Incorrect 6 ms 1188 KB Output isn't correct
11 Incorrect 8 ms 1232 KB Output isn't correct
12 Incorrect 8 ms 1232 KB Output isn't correct
13 Incorrect 36 ms 3180 KB Output isn't correct
14 Incorrect 137 ms 11024 KB Output isn't correct
15 Incorrect 293 ms 23008 KB Output isn't correct
16 Incorrect 457 ms 24272 KB Output isn't correct
17 Incorrect 357 ms 24928 KB Output isn't correct
18 Incorrect 382 ms 27232 KB Output isn't correct
19 Incorrect 414 ms 29904 KB Output isn't correct
20 Incorrect 503 ms 35316 KB Output isn't correct