Submission #150012

# Submission time Handle Problem Language Result Execution time Memory
150012 2019-09-01T07:33:07 Z GucciBelt(#3697, PeppaPig, win11905, DodgeBallMan) Crosses on the Grid (FXCUP4_cross) C++17
8 / 100
114 ms 5736 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;

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(), greater<pii>());
	priority_queue<int, vector<int>, greater<int> > Q;
	for(auto x : vec) {
		// cerr << x.x << ' ' << x.y << endl;
		Q.emplace(x.y);
		if(Q.size() == K+1) Q.pop();
		if(Q.size() == K) {
			int v = x.y;
			ans = max(ans, 1ll * x.x * x.x - 1ll * (x.x - v) * (x.x - v));
		}
	}
	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+1) Q.pop();
      ~~~~~~~~~^~~~~~
cross.cpp:22:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(Q.size() == K) {
      ~~~~~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Correct 6 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 11 ms 640 KB Output is correct
6 Correct 113 ms 5736 KB Output is correct
7 Correct 114 ms 5736 KB Output is correct
8 Correct 111 ms 5736 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 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 11 ms 640 KB Output is correct
6 Correct 113 ms 5736 KB Output is correct
7 Correct 114 ms 5736 KB Output is correct
8 Correct 111 ms 5736 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Incorrect 5 ms 256 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 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 11 ms 640 KB Output is correct
6 Correct 113 ms 5736 KB Output is correct
7 Correct 114 ms 5736 KB Output is correct
8 Correct 111 ms 5736 KB Output is correct
9 Correct 5 ms 256 KB Output is correct
10 Incorrect 5 ms 256 KB Output isn't correct
11 Halted 0 ms 0 KB -