답안 #89009

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
89009 2018-12-10T08:12:38 Z temoyanteladze 학교 설립 (IZhO13_school) C++14
15 / 100
604 ms 35308 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());

	multiset<ll>q;
    multiset <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>fat,sad;
		fat=*os1.rbegin();
	    sad=*os2.rbegin();
	    ll f1=-*q.begin();
	    
		if(f1+fat.x>sad.x)
		{
			ans+=f1+fat.x;
			q.erase(q.begin());
			ll p=fat.y-fat.x;
			q.insert(p);
			os1.erase(os1.find(fat));
			os2.erase(os2.find({fat.y, fat.x}));
	
		}
		 else{
			ans +=sad.x;
			os2.erase(os2.find(sad));
			os1.erase(os1.find({sad.y, sad.x}));
		 }
	}
cout<< ans;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 480 KB Output is correct
3 Correct 2 ms 480 KB Output is correct
4 Incorrect 2 ms 480 KB Output isn't correct
5 Incorrect 2 ms 604 KB Output isn't correct
6 Incorrect 2 ms 604 KB Output isn't correct
7 Incorrect 6 ms 1064 KB Output isn't correct
8 Incorrect 7 ms 1064 KB Output isn't correct
9 Incorrect 7 ms 1064 KB Output isn't correct
10 Incorrect 7 ms 1064 KB Output isn't correct
11 Incorrect 9 ms 1104 KB Output isn't correct
12 Incorrect 9 ms 1232 KB Output isn't correct
13 Incorrect 43 ms 3156 KB Output isn't correct
14 Incorrect 160 ms 10920 KB Output isn't correct
15 Incorrect 388 ms 22992 KB Output isn't correct
16 Incorrect 574 ms 24272 KB Output isn't correct
17 Incorrect 459 ms 24800 KB Output isn't correct
18 Incorrect 491 ms 27100 KB Output isn't correct
19 Incorrect 496 ms 29932 KB Output isn't correct
20 Incorrect 604 ms 35308 KB Output isn't correct