# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
222123 |
2020-04-12T07:08:25 Z |
Vimmer |
Kisik (COCI19_kisik) |
C++14 |
|
1368 ms |
75964 KB |
#include <bits/stdc++.h>
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")
#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 100005
#define MOD ll(998244353)
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, k;
cin >> n >> k;
pair <ll, ll> a[n];
for (int i = 0; i < n; i++) cin >> a[i].S >> a[i].F;
sort(a, a + n);
ll sum = 0, mx = 0, ans = 1e18;
for (int i = 0; i < n; i++) swap(a[i].F, a[i].S);
set <pair <ll, int> > se; se.clear();
for (int i = 0; i < k; i++) {sum += a[i].F; mx = a[i].S; se.insert({a[i].F, i}); }
ans = sum * mx;
for (int i = k; i < n; i++)
{
if ((*se.rbegin()).F <= a[i].F) continue;
pair <ll, int> nm = *se.rbegin();
se.erase(nm);
ll len = sum + a[i].F - nm.F;
ll hg = a[i].S;
sum = len; mx = hg; se.insert({a[i].F, i});
ans = min(ans, sum * mx);
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
104 ms |
4984 KB |
Output is correct |
2 |
Correct |
626 ms |
30200 KB |
Output is correct |
3 |
Correct |
719 ms |
47224 KB |
Output is correct |
4 |
Correct |
651 ms |
44104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
340 ms |
15456 KB |
Output is correct |
2 |
Correct |
58 ms |
6904 KB |
Output is correct |
3 |
Correct |
149 ms |
12408 KB |
Output is correct |
4 |
Correct |
610 ms |
38756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
244 ms |
16888 KB |
Output is correct |
2 |
Correct |
201 ms |
10188 KB |
Output is correct |
3 |
Correct |
236 ms |
11656 KB |
Output is correct |
4 |
Correct |
1368 ms |
75964 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
283 ms |
16120 KB |
Output is correct |
2 |
Correct |
1029 ms |
45920 KB |
Output is correct |
3 |
Correct |
260 ms |
17276 KB |
Output is correct |
4 |
Correct |
869 ms |
53860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
431 ms |
17904 KB |
Output is correct |
2 |
Correct |
709 ms |
40568 KB |
Output is correct |
3 |
Correct |
509 ms |
28384 KB |
Output is correct |
4 |
Correct |
326 ms |
25848 KB |
Output is correct |