Submission #150056

# Submission time Handle Problem Language Result Execution time Memory
150056 2019-09-01T07:38:06 Z 먀(#3635, khsoo01) Crosses on the Grid (FXCUP4_cross) C++17
100 / 100
124 ms 6876 KB
#include "cross.h"
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

long long SelectCross(int K, vector<int> I, vector<int> O) {
	vector<pii> V;
	int N = I.size();
	for(int i=0;i<N;i++) {
		V.push_back({-I[i], O[i]});
	}
	sort(V.begin(), V.end());
	priority_queue<int> Q;
	ll ans = 0;
	for(int i=0;i<N;i++) {
		Q.push(-V[i].Y);
		if(Q.size() > K) Q.pop();
		if(i >= K-1) ans = max(ans, -1ll*V[i].X*V[i].X +2ll*V[i].X*Q.top());
	}
	return ans;
}

Compilation message

cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:21:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(Q.size() > K) Q.pop();
      ~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 12 ms 768 KB Output is correct
6 Correct 117 ms 5740 KB Output is correct
7 Correct 114 ms 5736 KB Output is correct
8 Correct 114 ms 5740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 12 ms 768 KB Output is correct
6 Correct 117 ms 5740 KB Output is correct
7 Correct 114 ms 5736 KB Output is correct
8 Correct 114 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 6 ms 384 KB Output is correct
12 Correct 12 ms 640 KB Output is correct
13 Correct 62 ms 3180 KB Output is correct
14 Correct 114 ms 5744 KB Output is correct
15 Correct 115 ms 5584 KB Output is correct
16 Correct 118 ms 5608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 384 KB Output is correct
5 Correct 12 ms 768 KB Output is correct
6 Correct 117 ms 5740 KB Output is correct
7 Correct 114 ms 5736 KB Output is correct
8 Correct 114 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 6 ms 384 KB Output is correct
12 Correct 12 ms 640 KB Output is correct
13 Correct 62 ms 3180 KB Output is correct
14 Correct 114 ms 5744 KB Output is correct
15 Correct 115 ms 5584 KB Output is correct
16 Correct 118 ms 5608 KB Output is correct
17 Correct 6 ms 432 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 3180 KB Output is correct
21 Correct 92 ms 5096 KB Output is correct
22 Correct 118 ms 5772 KB Output is correct
23 Correct 123 ms 5736 KB Output is correct
24 Correct 124 ms 5736 KB Output is correct
25 Correct 120 ms 6632 KB Output is correct
26 Correct 118 ms 6876 KB Output is correct