#include <bits/stdc++.h>
#define pii pair<int,int>
#define ft first
#define sd second
using namespace std;
typedef long long ll;
const int N = 1000100;
const ll OO = 1e18;
priority_queue<int> st;
pii a[N];
int n, k;
ll sm = 0ll, ans = OO;
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
// freopen("in.txt","r",stdin);
cin >> n >> k;
for (int i = 0; i < n; i++)
cin >> a[i].sd >> a[i].ft;
sort(a, a + n);
for (int i = 0; i < n; i++){
st.push(a[i].sd);
sm += a[i].sd;
if (i >= k){
sm -= st.top();
st.pop();
}
if (i + 1 >= k)
ans = min(ans, ll(a[i].ft) * sm);
}
cout << ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
112 ms |
6672 KB |
Output is correct |
2 |
Correct |
268 ms |
15964 KB |
Output is correct |
3 |
Correct |
223 ms |
17388 KB |
Output is correct |
4 |
Correct |
201 ms |
16364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
194 ms |
10612 KB |
Output is correct |
2 |
Correct |
31 ms |
2688 KB |
Output is correct |
3 |
Correct |
63 ms |
4848 KB |
Output is correct |
4 |
Correct |
177 ms |
12784 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
96 ms |
6772 KB |
Output is correct |
2 |
Correct |
214 ms |
12024 KB |
Output is correct |
3 |
Correct |
155 ms |
9080 KB |
Output is correct |
4 |
Correct |
355 ms |
24988 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
129 ms |
8052 KB |
Output is correct |
2 |
Correct |
371 ms |
21488 KB |
Output is correct |
3 |
Correct |
112 ms |
7504 KB |
Output is correct |
4 |
Correct |
250 ms |
18924 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
269 ms |
14968 KB |
Output is correct |
2 |
Correct |
239 ms |
15600 KB |
Output is correct |
3 |
Correct |
194 ms |
12784 KB |
Output is correct |
4 |
Correct |
114 ms |
9328 KB |
Output is correct |