답안 #96698

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
96698 2019-02-11T05:19:43 Z nandonathaniel Kisik (COCI19_kisik) C++14
90 / 90
699 ms 54604 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MAXN=1000000;

vector<LL> rec[MAXN+5];
priority_queue<LL> PQ;

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    LL n,k,h,w;
    cin >> n >> k;
    for(LL i=1;i<=n;i++){
    	cin >> w >> h;
    	rec[h].push_back(w);
	}
	LL res=0;
	LL ans=2e18;
	for(LL i=1;i<=MAXN;i++){
		for(LL j=0;j<rec[i].size();j++){
			res+=rec[i][j];
			PQ.push(rec[i][j]);
			if(PQ.size()==k){
				ans=min(ans,res*i);
				LL gede=PQ.top();
				PQ.pop();
				res-=gede;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Compilation message

kisik.cpp: In function 'int main()':
kisik.cpp:22:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(LL j=0;j<rec[i].size();j++){
              ~^~~~~~~~~~~~~~
kisik.cpp:25:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(PQ.size()==k){
       ~~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 23800 KB Output is correct
2 Correct 21 ms 23800 KB Output is correct
3 Correct 20 ms 23800 KB Output is correct
4 Correct 26 ms 23800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 23928 KB Output is correct
2 Correct 25 ms 23900 KB Output is correct
3 Correct 21 ms 24060 KB Output is correct
4 Correct 20 ms 23800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 23800 KB Output is correct
2 Correct 20 ms 23800 KB Output is correct
3 Correct 20 ms 23800 KB Output is correct
4 Correct 20 ms 23800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 23800 KB Output is correct
2 Correct 25 ms 23800 KB Output is correct
3 Correct 23 ms 23928 KB Output is correct
4 Correct 20 ms 23800 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 216 ms 32732 KB Output is correct
2 Correct 464 ms 43840 KB Output is correct
3 Correct 398 ms 47568 KB Output is correct
4 Correct 351 ms 46616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 329 ms 37904 KB Output is correct
2 Correct 69 ms 28400 KB Output is correct
3 Correct 114 ms 31636 KB Output is correct
4 Correct 335 ms 41328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 175 ms 34008 KB Output is correct
2 Correct 442 ms 38672 KB Output is correct
3 Correct 294 ms 36076 KB Output is correct
4 Correct 640 ms 54604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 215 ms 35616 KB Output is correct
2 Correct 699 ms 49860 KB Output is correct
3 Correct 174 ms 34664 KB Output is correct
4 Correct 418 ms 49192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 439 ms 41700 KB Output is correct
2 Correct 440 ms 43968 KB Output is correct
3 Correct 315 ms 41260 KB Output is correct
4 Correct 214 ms 37736 KB Output is correct