Submission #150548

# Submission time Handle Problem Language Result Execution time Memory
150548 2019-09-01T08:37:17 Z Ian and 2-bit memory(#3648, percywtc, nhho, ulna) Crosses on the Grid (FXCUP4_cross) C++17
100 / 100
124 ms 6636 KB
#include <bits/stdc++.h>

using namespace std;

#include "cross.h"

long long SelectCross(int K, vector<int> I, vector<int> O) {
	int N = I.size();
	vector<pair<int, int>> v(N);
	for (int i = 0; i < N; i++)
		v[i] = {O[i], I[i]};
	sort(v.begin(), v.end(), greater<pair<int, int>>());
	priority_queue<int, vector<int>, greater<int>> q;
	long long ans = 0;
	for (auto& i : v) {
		q.push(i.second);
		if (q.size() > K)
			q.pop();
		if (q.size() == K) {
			long long ta = i.first;
			long long tb = ta - q.top();
			ans = max(ans, ta * ta - tb * tb);
		}
	}
	return ans;
}

Compilation message

cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:17:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (q.size() > K)
       ~~~~~~~~~^~~
cross.cpp:19:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (q.size() == K) {
       ~~~~~~~~~^~~~
# 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 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 12 ms 640 KB Output is correct
6 Correct 110 ms 5228 KB Output is correct
7 Correct 112 ms 5224 KB Output is correct
8 Correct 106 ms 5228 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 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 12 ms 640 KB Output is correct
6 Correct 110 ms 5228 KB Output is correct
7 Correct 112 ms 5224 KB Output is correct
8 Correct 106 ms 5228 KB Output is correct
9 Correct 6 ms 264 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 11 ms 640 KB Output is correct
13 Correct 62 ms 2924 KB Output is correct
14 Correct 114 ms 5224 KB Output is correct
15 Correct 114 ms 5228 KB Output is correct
16 Correct 111 ms 5224 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 6 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 12 ms 640 KB Output is correct
6 Correct 110 ms 5228 KB Output is correct
7 Correct 112 ms 5224 KB Output is correct
8 Correct 106 ms 5228 KB Output is correct
9 Correct 6 ms 264 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 6 ms 384 KB Output is correct
12 Correct 11 ms 640 KB Output is correct
13 Correct 62 ms 2924 KB Output is correct
14 Correct 114 ms 5224 KB Output is correct
15 Correct 114 ms 5228 KB Output is correct
16 Correct 111 ms 5224 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 12 ms 768 KB Output is correct
20 Correct 62 ms 2928 KB Output is correct
21 Correct 89 ms 4204 KB Output is correct
22 Correct 112 ms 5228 KB Output is correct
23 Correct 115 ms 5228 KB Output is correct
24 Correct 124 ms 5352 KB Output is correct
25 Correct 118 ms 6636 KB Output is correct
26 Correct 114 ms 6636 KB Output is correct