답안 #168280

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
168280 2019-12-12T08:38:36 Z juggernaut 학교 설립 (IZhO13_school) C++14
20 / 100
221 ms 8568 KB
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int n,a,b,i,c1,c2;
pair<int,int>v[300001];
bool fr(pair<int,int>l,pair<int,int>r){
    return l.first>r.first||l.first==r.first&&l.second<r.second;
}
bool sc(pair<int,int>l,pair<int,int>r){
    return l.second>r.second||l.second==r.second&&l.first<r.first;
}
main(){
    scanf("%lld%lld%lld",&n,&a,&b);
    for(i=1;i<=n;i++)scanf("%lld%lld",&v[i].first,&v[i].second);
    sort(v+1,v+1+n,fr);
    for(i=1;i<=a;i++)c1+=v[i].first;
    sort(v+1+a,v+1+n,sc);
    for(i=a+1;i<=a+b;i++)c1+=v[i].second;
    sort(v+1,v+1+n,sc);
    for(i=1;i<=b;i++)c2+=v[i].second;
    sort(v+1+b,v+1+n,fr);
    for(i=b+1;i<=a+b;i++)c2+=v[i].first;
    cout<<max(c1,c2);
}

Compilation message

school.cpp: In function 'bool fr(std::pair<long long int, long long int>, std::pair<long long int, long long int>)':
school.cpp:7:45: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
     return l.first>r.first||l.first==r.first&&l.second<r.second;
                             ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
school.cpp: In function 'bool sc(std::pair<long long int, long long int>, std::pair<long long int, long long int>)':
school.cpp:10:49: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
     return l.second>r.second||l.second==r.second&&l.first<r.first;
                               ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
school.cpp: At global scope:
school.cpp:12:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
school.cpp: In function 'int main()':
school.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld%lld",&n,&a,&b);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
school.cpp:14:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(i=1;i<=n;i++)scanf("%lld%lld",&v[i].first,&v[i].second);
                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 252 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Incorrect 2 ms 256 KB Output isn't correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Incorrect 4 ms 376 KB Output isn't correct
8 Incorrect 4 ms 504 KB Output isn't correct
9 Incorrect 5 ms 504 KB Output isn't correct
10 Incorrect 5 ms 504 KB Output isn't correct
11 Incorrect 5 ms 504 KB Output isn't correct
12 Incorrect 5 ms 380 KB Output isn't correct
13 Incorrect 25 ms 1400 KB Output isn't correct
14 Incorrect 58 ms 2556 KB Output isn't correct
15 Correct 153 ms 4604 KB Output is correct
16 Incorrect 125 ms 5112 KB Output isn't correct
17 Incorrect 152 ms 6392 KB Output isn't correct
18 Incorrect 177 ms 6980 KB Output isn't correct
19 Incorrect 193 ms 7544 KB Output isn't correct
20 Incorrect 221 ms 8568 KB Output isn't correct