답안 #88999

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
88999 2018-12-10T07:56:13 Z temoyanteladze 학교 설립 (IZhO13_school) C++14
5 / 100
471 ms 54932 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 684 KB Output is correct
3 Runtime error 5 ms 976 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 5 ms 976 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 5 ms 976 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 7 ms 1032 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 12 ms 2200 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 10 ms 2200 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 8 ms 2200 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 10 ms 2200 KB Execution killed with signal 11 (could be triggered by violating memory limits)
11 Runtime error 12 ms 2468 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 10 ms 2468 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 44 ms 5340 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 159 ms 21596 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 333 ms 46060 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 401 ms 47944 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 324 ms 47944 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 369 ms 47944 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 433 ms 47944 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 471 ms 54932 KB Execution killed with signal 11 (could be triggered by violating memory limits)