답안 #801942

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
801942 2023-08-02T08:32:29 Z Trisanu_Das Kisik (COCI19_kisik) C++17
90 / 90
974 ms 65504 KB
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
const int maxn = 1e6 + 10;
const ll inf = 1e18;
 
pair<int, int> a[maxn];
 
int main(){
	ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i].second >> a[i].first;
	sort(a, a + n);
	multiset<int> s;
	ll answer = inf;
	ll sum = 0;
	for (int i = 0; i < n; i++){
		s.insert(a[i].second);
		sum += a[i].second;
		if (s.size() > k){
			auto it = s.end();
			it --;
			sum -= *it;
			s.erase(it);
		}
		if (s.size() == k)
			answer = min(answer, 1ll * sum * a[i].first);
	}
	cout << answer << endl;
}

Compilation message

kisik.cpp: In function 'int main()':
kisik.cpp:24:16: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   24 |   if (s.size() > k){
      |       ~~~~~~~~~^~~
kisik.cpp:30:16: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |   if (s.size() == k)
      |       ~~~~~~~~~^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 6580 KB Output is correct
2 Correct 413 ms 28332 KB Output is correct
3 Correct 546 ms 40776 KB Output is correct
4 Correct 481 ms 37932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 171 ms 15648 KB Output is correct
2 Correct 33 ms 5532 KB Output is correct
3 Correct 67 ms 10480 KB Output is correct
4 Correct 362 ms 33076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 124 ms 15036 KB Output is correct
2 Correct 145 ms 12300 KB Output is correct
3 Correct 132 ms 11732 KB Output is correct
4 Correct 974 ms 65504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 151 ms 14960 KB Output is correct
2 Correct 674 ms 42328 KB Output is correct
3 Correct 122 ms 15076 KB Output is correct
4 Correct 575 ms 46376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 227 ms 19688 KB Output is correct
2 Correct 372 ms 35600 KB Output is correct
3 Correct 283 ms 25284 KB Output is correct
4 Correct 175 ms 21892 KB Output is correct