답안 #96665

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
96665 2019-02-10T17:04:13 Z Ort Kisik (COCI19_kisik) C++11
90 / 90
1905 ms 91652 KB
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#define ll long long

using namespace std;

ll prefsum[1000005];
vector<pair<int,int> > bprints_h;
vector<pair<int,int> > bprints_w;
map<pair<int,int>,int> M;
map<int,pair<int,int> > used;

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	int n, k, w, h;
	cin >> n >> k;
	for(int i=0;i<n;i++) {
		cin >> w >> h;
		bprints_h.push_back(make_pair(h,w));
		bprints_w.push_back(make_pair(w,h));
	}
	sort(bprints_h.begin(),bprints_h.end(),greater<pair<int,int> >());
	sort(bprints_w.begin(),bprints_w.end());
	M.insert(make_pair(make_pair(bprints_w[0].first, bprints_w[0].second),0));
	prefsum[0] =  bprints_w[0].first;
	for(int i=1;i<n;i++) {
		M.insert(make_pair(make_pair(bprints_w[i].first, bprints_w[i].second),i));
		prefsum[i] = prefsum[i-1] + bprints_w[i].first;
	}
	int index, i=0; 
	ll diff = 0, sum = 0, sol = 1000000000000000000;
	while(n>=k) {
		index = M.find(make_pair(bprints_h[i].second,bprints_h[i].first))->second;
		sum = prefsum[k-1];
		sum -= diff;
		sol = min(sol, bprints_h[i].first*sum);
		if(index>k) used.insert(make_pair(index,make_pair(bprints_h[i].second,bprints_h[i].first)));
		if(index<=k) {
			k++; diff += bprints_h[i].second;
			while(used.find(k)!=used.end()) {
				diff += (used.find(k)->second.first);
				k++;
			}
		}
		i++;
	}
	cout << sol;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 884 ms 47468 KB Output is correct
2 Correct 1008 ms 67964 KB Output is correct
3 Correct 485 ms 60460 KB Output is correct
4 Correct 462 ms 55432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 850 ms 50940 KB Output is correct
2 Correct 62 ms 8168 KB Output is correct
3 Correct 116 ms 15740 KB Output is correct
4 Correct 363 ms 48252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 225 ms 24928 KB Output is correct
2 Correct 1905 ms 84628 KB Output is correct
3 Correct 774 ms 49732 KB Output is correct
4 Correct 762 ms 91652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 366 ms 33376 KB Output is correct
2 Correct 1243 ms 91516 KB Output is correct
3 Correct 273 ms 28212 KB Output is correct
4 Correct 522 ms 67592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1691 ms 87212 KB Output is correct
2 Correct 663 ms 61608 KB Output is correct
3 Correct 582 ms 49888 KB Output is correct
4 Correct 234 ms 31944 KB Output is correct