Submission #150073

# Submission time Handle Problem Language Result Execution time Memory
150073 2019-09-01T07:40:26 Z GucciBelt(#3697, PeppaPig, win11905, DodgeBallMan) Crosses on the Grid (FXCUP4_cross) C++17
100 / 100
128 ms 6760 KB
#include <bits/stdc++.h>
#include "cross.h"
#define long long long 
#define pii pair<int, int>
#define x first
#define y second
using namespace std;

const int INF = 1e9+1;

int n;
long ans;

long SelectCross(int K, vector<int> I, vector<int> O) {
	n = I.size();
	vector<pii> vec;
	for(int i = 0; i < n; ++i) vec.emplace_back(O[i], I[i]);
	sort(vec.begin(), vec.end(), [&](const pii &a, const pii &b) {
		if(a.x != b.x) return a.x > b.x;
		return a.y < b.y;
	});
	priority_queue<int, vector<int>, greater<int> > Q;
	for(auto x : vec) {
		// cerr << x.x << ' ' << x.y << endl;

		if(Q.size() == K) Q.pop();
		if(Q.size() == K-1) {
			int v = min(x.y, Q.empty() ? INF : Q.top());
			ans = max(ans, 1ll * x.x * x.x - 1ll * (x.x - v) * (x.x - v));
		}
		Q.emplace(x.y);
	}
	return ans;
}

Compilation message

cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:26:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(Q.size() == K) Q.pop();
      ~~~~~~~~~^~~~
cross.cpp:27:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(Q.size() == K-1) {
      ~~~~~~~~~^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 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 13 ms 768 KB Output is correct
6 Correct 120 ms 5736 KB Output is correct
7 Correct 112 ms 5736 KB Output is correct
8 Correct 116 ms 5740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 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 13 ms 768 KB Output is correct
6 Correct 120 ms 5736 KB Output is correct
7 Correct 112 ms 5736 KB Output is correct
8 Correct 116 ms 5740 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 7 ms 384 KB Output is correct
12 Correct 12 ms 768 KB Output is correct
13 Correct 63 ms 3184 KB Output is correct
14 Correct 120 ms 5740 KB Output is correct
15 Correct 116 ms 5740 KB Output is correct
16 Correct 118 ms 5736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 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 13 ms 768 KB Output is correct
6 Correct 120 ms 5736 KB Output is correct
7 Correct 112 ms 5736 KB Output is correct
8 Correct 116 ms 5740 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 7 ms 384 KB Output is correct
12 Correct 12 ms 768 KB Output is correct
13 Correct 63 ms 3184 KB Output is correct
14 Correct 120 ms 5740 KB Output is correct
15 Correct 116 ms 5740 KB Output is correct
16 Correct 118 ms 5736 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 6 ms 384 KB Output is correct
19 Correct 12 ms 640 KB Output is correct
20 Correct 65 ms 3184 KB Output is correct
21 Correct 98 ms 5096 KB Output is correct
22 Correct 125 ms 5608 KB Output is correct
23 Correct 119 ms 5484 KB Output is correct
24 Correct 128 ms 5612 KB Output is correct
25 Correct 123 ms 6620 KB Output is correct
26 Correct 120 ms 6760 KB Output is correct