답안 #89000

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
89000 2018-12-10T07:57:54 Z temoyanteladze 학교 설립 (IZhO13_school) C++14
5 / 100
487 ms 54724 KB
#include <bits/stdc++.h>
#define ll long long
#define x first
#define y second
using namespace std;

int main() {
ll n,l,r;
ll ans=0;
vector<pair<ll,ll> >a;

    cin>>n>>l>>r;
    a.resize(n+1);
	for(ll i=1;i<=n;i++)
		cin>>a[i].x>>a[i].y;
		
	sort(a.begin()+1,a.end());
	reverse(a.begin()+1,a.end());

	set<ll>q;
    set <pair<ll,ll> > os1,os2;

	for(ll i=1;i<=l;i++)
	{
		ans+=a[i].x;
		q.insert(-a[i].y+a[i].x);
	}
	
	for(ll i=l+1;i<=n;i++)
	{
		os1.insert(a[i]);
		os2.insert({a[i].y,a[i].x});
	}

	for (ll i=r;i>0;i--){
		pair<ll,ll>ft,sd;
		ft=*os1.rbegin();
	    sd=*os2.rbegin();
	    ll f1=-*q.begin();
	    
		if(f1+ft.x>sd.x)
		{
			ans+=ft.x+sd.x;
			q.erase(q.begin());
			os1.erase(os1.find(ft));
			os2.erase(os2.find({ft.x, ft.y}));
			q.insert(ft.y-ft.x);
		}
		 else{
			ans +=sd.x;
			os2.erase(os2.find(sd));
			os1.erase(os1.find({sd.y, sd.x}));
		 }
	}
cout<< ans;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 632 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Correct 2 ms 632 KB Output is correct
3 Runtime error 5 ms 848 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 5 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 5 ms 916 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 6 ms 1144 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 11 ms 2324 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 10 ms 2324 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 7 ms 2324 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 10 ms 2324 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 13 ms 2468 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 9 ms 2468 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 42 ms 5304 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 134 ms 21684 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 326 ms 45912 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 366 ms 47836 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 354 ms 47836 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 368 ms 47836 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 449 ms 47836 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 487 ms 54724 KB Execution killed with signal 11 (could be triggered by violating memory limits)