Submission #640875

# Submission time Handle Problem Language Result Execution time Memory
640875 2022-09-15T12:40:12 Z andreast12 Kisik (COCI19_kisik) C++17
90 / 90
283 ms 36432 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define pb push_back
const int mod=998244353, maxn=1e6+5;
int n, k;
pair<ll, ll> a[maxn];
priority_queue<ll> pq;
ll tot, ans;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> n >> k;
	for(int i=1; i<=n; i++) cin >> a[i].se >> a[i].fi;
	sort(a+1, a+n+1);
	for(int i=1; i<=k; i++) {
		pq.push(a[i].se);
		tot+=a[i].se;
	}
	ans=a[k].fi*tot;
	for(int i=k+1; i<=n; i++) {
		if(a[i].se<pq.top()) {
			tot-=pq.top()-a[i].se;
			pq.pop();
			pq.push(a[i].se);
		}
		ans=min(ans, a[i].fi*tot);
	}
	cout << ans << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 328 KB Output is correct
# Verdict Execution time Memory 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
# Verdict Execution time Memory Grader output
1 Correct 81 ms 8872 KB Output is correct
2 Correct 190 ms 22656 KB Output is correct
3 Correct 158 ms 26148 KB Output is correct
4 Correct 154 ms 24724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 130 ms 14840 KB Output is correct
2 Correct 20 ms 3720 KB Output is correct
3 Correct 39 ms 6972 KB Output is correct
4 Correct 128 ms 18616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 9616 KB Output is correct
2 Correct 141 ms 16316 KB Output is correct
3 Correct 109 ms 12432 KB Output is correct
4 Correct 265 ms 36432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 87 ms 11460 KB Output is correct
2 Correct 283 ms 30376 KB Output is correct
3 Correct 83 ms 10408 KB Output is correct
4 Correct 178 ms 28328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 186 ms 20616 KB Output is correct
2 Correct 172 ms 22160 KB Output is correct
3 Correct 140 ms 18456 KB Output is correct
4 Correct 91 ms 13792 KB Output is correct