답안 #208311

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
208311 2020-03-10T16:41:01 Z mohamedsobhi777 학교 설립 (IZhO13_school) C++14
25 / 100
357 ms 11244 KB
#include<bits/stdc++.h> 
 
using namespace std ;

const int N = 1e6 + 7 , mod = 998244353; 

long long n   , A , B; 
long long a[N] , b[N] ; 
long long ans ; 
int gA , gB ; 

priority_queue<pair<long long , long long > > q1 , q2 ;

int main() 
{
    //freopen("in.in" , "r" , stdin) ; 
    cin>>n>>A>>B ; 
    for(int i = 0 ; i < n ; i++){
        cin>>a[i] >> b[i] ; 
        if(a[i]>=b[i]){
            q1.push({ b[i] -a[i],i });
        }
        else {
            q2.push({a[i] - b[i] , i}) ; 
        }
        ans += max(a[i] , b[i] ) ;
    }
    while(q1.size()> A && q2.size() < B){
        ans+=q1.top().first ; 
        q2.push({a[q1.top().second] - b[q1.top().second] ,q1.top().second });
        q1.pop(); 
    }
    while(q2.size()> B && q1.size() < A){
        ans+=q2.top().first ; 
        q1.push({b[q2.top().second] - a[q2.top().second] , q2.top().second}) ;
        q2.pop(); 
    }
    if(q1.size() > A){
        priority_queue<int> aux ; 
        while(q1.size()){
            aux.push(-a[q1.top().second]) ; 
            q1.pop() ; 
        }
        while(A--){
            ans+=aux.top() ; 
            aux.pop();
        }
    }
    if(q2.size() > B){
        priority_queue<int> aux ; 
        while(q2.size()){
            aux.push(-b[q2.top().second]) ; 
            q2.pop() ; 
        }
        while(B--){
            ans+=aux.top() ; 
            aux.pop();
        }
    }
    cout<<ans; 
    return 0 ;  
}

Compilation message

school.cpp: In function 'int main()':
school.cpp:28:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(q1.size()> A && q2.size() < B){
           ~~~~~~~~~^~~
school.cpp:28:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(q1.size()> A && q2.size() < B){
                           ~~~~~~~~~~^~~
school.cpp:33:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(q2.size()> B && q1.size() < A){
           ~~~~~~~~~^~~
school.cpp:33:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(q2.size()> B && q1.size() < A){
                           ~~~~~~~~~~^~~
school.cpp:38:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(q1.size() > A){
        ~~~~~~~~~~^~~
school.cpp:49:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(q2.size() > B){
        ~~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Incorrect 5 ms 376 KB Output isn't correct
5 Incorrect 5 ms 376 KB Output isn't correct
6 Incorrect 5 ms 376 KB Output isn't correct
7 Incorrect 9 ms 504 KB Output isn't correct
8 Correct 9 ms 632 KB Output is correct
9 Incorrect 9 ms 504 KB Output isn't correct
10 Incorrect 9 ms 632 KB Output isn't correct
11 Incorrect 11 ms 552 KB Output isn't correct
12 Incorrect 9 ms 636 KB Output isn't correct
13 Incorrect 38 ms 1904 KB Output isn't correct
14 Incorrect 86 ms 3208 KB Output isn't correct
15 Incorrect 174 ms 6156 KB Output isn't correct
16 Correct 176 ms 8912 KB Output is correct
17 Incorrect 262 ms 8272 KB Output isn't correct
18 Incorrect 281 ms 8852 KB Output isn't correct
19 Incorrect 317 ms 9492 KB Output isn't correct
20 Incorrect 357 ms 11244 KB Output isn't correct