답안 #90803

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
90803 2018-12-24T13:17:31 Z Aydarov03 학교 설립 (IZhO13_school) C++14
5 / 100
1128 ms 40096 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()
{
    multiset < ll > rz;
    multiset < pii> v1 , v2;

    ll x , y;
    ll 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} );
    }

    puts("");
    for(auto c : v1)cout << c.fr << " " << c.sc << endl;
    puts("");
    for(auto c : v2)cout << c.fr << " " << c.sc << endl;


    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()
      ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Correct 2 ms 372 KB Output is correct
3 Incorrect 2 ms 536 KB Output isn't correct
4 Incorrect 2 ms 580 KB Output isn't correct
5 Incorrect 2 ms 580 KB Output isn't correct
6 Incorrect 2 ms 580 KB Output isn't correct
7 Incorrect 19 ms 1172 KB Output isn't correct
8 Incorrect 6 ms 1172 KB Output isn't correct
9 Incorrect 8 ms 1172 KB Output isn't correct
10 Incorrect 8 ms 1172 KB Output isn't correct
11 Incorrect 22 ms 1276 KB Output isn't correct
12 Incorrect 23 ms 1420 KB Output isn't correct
13 Incorrect 51 ms 3300 KB Output isn't correct
14 Incorrect 359 ms 12652 KB Output isn't correct
15 Incorrect 805 ms 26612 KB Output isn't correct
16 Incorrect 940 ms 27784 KB Output isn't correct
17 Incorrect 779 ms 28036 KB Output isn't correct
18 Incorrect 879 ms 30724 KB Output isn't correct
19 Incorrect 930 ms 34052 KB Output isn't correct
20 Incorrect 1128 ms 40096 KB Output isn't correct