# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
168280 | juggernaut | 학교 설립 (IZhO13_school) | C++14 | 221 ms | 8568 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |