Submission #762356

# Submission time Handle Problem Language Result Execution time Memory
762356 2023-06-21T10:36:13 Z goodbyehanbyeol Crosses on the Grid (FXCUP4_cross) C++17
100 / 100
105 ms 20044 KB
#include "cross.h"
#include <bits/stdc++.h>
using namespace std;

long long SelectCross(int k, std::vector<int> I, std::vector<int> O) {
	int n = I.size();
	vector<vector<int>> a(n, vector<int>(2));
	for(int i = 0; i < n; ++i){
		a[i][0] = O[i];
		a[i][1] = I[i];
	}
	sort(a.begin(), a.end());
	priority_queue<int> mx;
	priority_queue<int, vector<int>, greater<int>> mn;
	long long ans = 0;
	for(int i = n - 1; i >= 0; --i){
		if(!(int)mx.size() || a[i][1] > mx.top()) mn.push(a[i][1]);
		else mx.push(a[i][1]);
		while((int)mn.size() >= k){
			mx.push(mn.top());
			mn.pop();
		}
		while((int)mn.size() < k - 1 && (int)mx.size()){
			mn.push(mx.top());
			mx.pop();
		}

		if(i + k <= n){
			ans = max(ans, (long long)a[i][0] * a[i][0] - (long long)(a[i][0] - mx.top()) * (a[i][0] - mx.top()));
		}
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 4 ms 1412 KB Output is correct
6 Correct 84 ms 19708 KB Output is correct
7 Correct 83 ms 19776 KB Output is correct
8 Correct 82 ms 19688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 4 ms 1412 KB Output is correct
6 Correct 84 ms 19708 KB Output is correct
7 Correct 83 ms 19776 KB Output is correct
8 Correct 82 ms 19688 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 5 ms 1492 KB Output is correct
13 Correct 38 ms 10220 KB Output is correct
14 Correct 95 ms 19712 KB Output is correct
15 Correct 105 ms 19760 KB Output is correct
16 Correct 88 ms 19744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 304 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 4 ms 1412 KB Output is correct
6 Correct 84 ms 19708 KB Output is correct
7 Correct 83 ms 19776 KB Output is correct
8 Correct 82 ms 19688 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 5 ms 1492 KB Output is correct
13 Correct 38 ms 10220 KB Output is correct
14 Correct 95 ms 19712 KB Output is correct
15 Correct 105 ms 19760 KB Output is correct
16 Correct 88 ms 19744 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 5 ms 1580 KB Output is correct
20 Correct 40 ms 10164 KB Output is correct
21 Correct 61 ms 15984 KB Output is correct
22 Correct 77 ms 19792 KB Output is correct
23 Correct 83 ms 19792 KB Output is correct
24 Correct 82 ms 20044 KB Output is correct
25 Correct 91 ms 19800 KB Output is correct
26 Correct 78 ms 19756 KB Output is correct