Submission #759939

# Submission time Handle Problem Language Result Execution time Memory
759939 2023-06-17T05:41:24 Z jk410 Crosses on the Grid (FXCUP4_cross) C++17
100 / 100
66 ms 12620 KB
#include <bits/stdc++.h>
#include "cross.h"
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;

ll calc(ll i, ll o) {
	return 2 * o * i - i * i;
}

ll SelectCross(int K, std::vector<int> I, std::vector<int> O) {
	int n = (int)I.size();
	vector<pair<ll,ll>> c(n);
	for (int i = 0; i < n; i++)
		c[i] = { I[i],O[i] };
	sort(all(c));
	reverse(all(c));
	priority_queue<ll> q;
	for (int i = 0; i < K; i++)
		q.push(-c[i].second);
	ll ret = calc(c[K - 1].first, -q.top());
	for (int i = K; i < n; i++) {
		q.push(-c[i].second);
		q.pop();
		ret = max(ret, calc(c[i].first, -q.top()));
	}
	return ret;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 3 ms 932 KB Output is correct
6 Correct 66 ms 10536 KB Output is correct
7 Correct 62 ms 10556 KB Output is correct
8 Correct 52 ms 10472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 3 ms 932 KB Output is correct
6 Correct 66 ms 10536 KB Output is correct
7 Correct 62 ms 10556 KB Output is correct
8 Correct 52 ms 10472 KB Output is correct
9 Correct 0 ms 296 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 3 ms 852 KB Output is correct
13 Correct 29 ms 5472 KB Output is correct
14 Correct 54 ms 10436 KB Output is correct
15 Correct 55 ms 10436 KB Output is correct
16 Correct 55 ms 10568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 3 ms 932 KB Output is correct
6 Correct 66 ms 10536 KB Output is correct
7 Correct 62 ms 10556 KB Output is correct
8 Correct 52 ms 10472 KB Output is correct
9 Correct 0 ms 296 KB Output is correct
10 Correct 1 ms 304 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 3 ms 852 KB Output is correct
13 Correct 29 ms 5472 KB Output is correct
14 Correct 54 ms 10436 KB Output is correct
15 Correct 55 ms 10436 KB Output is correct
16 Correct 55 ms 10568 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 312 KB Output is correct
19 Correct 4 ms 1128 KB Output is correct
20 Correct 34 ms 5544 KB Output is correct
21 Correct 51 ms 8332 KB Output is correct
22 Correct 57 ms 10480 KB Output is correct
23 Correct 59 ms 10428 KB Output is correct
24 Correct 60 ms 10904 KB Output is correct
25 Correct 65 ms 12616 KB Output is correct
26 Correct 56 ms 12620 KB Output is correct