답안 #90730

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
90730 2018-12-24T05:57:52 Z Aydarov03 학교 설립 (IZhO13_school) C++14
0 / 100
223 ms 22248 KB
#include <bits/stdc++.h>
#define int long long
#define fr first
#define sc second

using namespace std;

const int N = 2e5+10;
const int inf = 1e9+7;

bool cmp( pair<int,int> a, pair<int,int> b)
{
    a.sc > b.sc;
}

pair <int,int> a[300005];
vector < pair<int,int> > v1 , v2;


main()
{


    int n , m , s , ans = 0;
    cin >> n >> m >> s;

    int cnt1 = m , cnt2 = s;

    for(int i = 1; i <= n; i++)
        cin >> a[i].fr >> a[i].sc;




    sort( a + 1 , a + n + 1 );
    for(int i = 1; i <= n; i++)v1.push_back( a[i] );
    sort( a + 1 , a + n + 1 , &cmp);
    for(int i = 1; i <= n; i++)v2.push_back( a[i] );



    for(int i = 0; i < n; i += 2)
    {
        if( cnt1 == 0 )
        {
            while( cnt2-- )ans += v2[i].sc;
            break;
        }
        else if( cnt2 == 0 )
        {
            while( cnt1-- )ans += v1[i].fr;
            break;
        }
        else
        {
            ans += max( v1[i].fr + v2[i+1].sc , v1[i+1].fr + v2[i].sc);
            cnt1-- , cnt2--;
        }
    }

    cout << ans;

}

Compilation message

school.cpp: In function 'bool cmp(std::pair<long long int, long long int>, std::pair<long long int, long long int>)':
school.cpp:13:10: warning: statement has no effect [-Wunused-value]
     a.sc > b.sc;
          ^
school.cpp:14:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
school.cpp: At global scope:
school.cpp:20: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 Incorrect 2 ms 372 KB Output isn't correct
3 Incorrect 2 ms 576 KB Output isn't correct
4 Runtime error 5 ms 592 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 4 ms 708 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 4 ms 772 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 7 ms 1408 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 7 ms 1408 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 7 ms 1408 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 7 ms 1424 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 8 ms 1468 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 7 ms 1472 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 28 ms 3368 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 57 ms 6048 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 114 ms 11160 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 128 ms 12980 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 174 ms 14836 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 184 ms 16220 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 202 ms 17340 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 223 ms 22248 KB Execution killed with signal 11 (could be triggered by violating memory limits)