제출 #328874

#제출 시각아이디문제언어결과실행 시간메모리
328874cgiosy학교 설립 (IZhO13_school)C++17
25 / 100
111 ms3820 KiB
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

struct pii {
	int a, b;
	bool operator<(const pii t) const { return a>t.a || a==t.a && b>t.b; }
};
int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	int N, X, Y;
	cin>>N>>X>>Y;
	vector<pii> A(N);
	for(auto&[a,b]:A) cin>>a>>b;
	sort(A.begin(), A.end());
	for(int i=X; i<N; i++) swap(A[i].a, A[i].b);
	sort(A.begin()+X, A.end());
	priority_queue<int> Qa, Qb;
	ll s=0;
	for(int i=0; i<X+Y; i++) s+=A[i].a, (i<X ? Qa : Qb).push(A[i].b-A[i].a);
	if(X && Y) while(true) {
		int a=Qa.top(); Qa.pop();
		int b=Qb.top(); Qb.pop();
		if(a+b<=0) break;
		s+=a+b;
		Qb.push(-a);
		Qa.push(-b);
	}
	cout<<s<<'\n';
}

컴파일 시 표준 에러 (stderr) 메시지

school.cpp: In member function 'bool pii::operator<(pii) const':
school.cpp:7:61: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
    7 |  bool operator<(const pii t) const { return a>t.a || a==t.a && b>t.b; }
      |                                                      ~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...