Submission #832424

# Submission time Handle Problem Language Result Execution time Memory
832424 2023-08-21T10:14:35 Z _martynas Crosses on the Grid (FXCUP4_cross) C++17
0 / 100
1 ms 280 KB
#include "cross.h"
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>

using namespace std;

long long SelectCross(int K, vector<int> I, vector<int> O) {
	int N = I.size();
	long long mx = 0;
	vector<int> orderI(N);
	iota(orderI.begin(), orderI.end(), 0);
	sort(orderI.begin(), orderI.end(), [&](int i, int j) { return I[i] > I[j]; });
	long long mndi = 1e15;
	multiset<long long> maxo;
	for(int i = 0, j = 0; i < N; i++) {
		mndi = I[orderI[i]];
		if(maxo.size() < K || (*maxo.begin()) < O[i]) {
			maxo.insert(O[i]);
			if(maxo.size() > K) maxo.erase(maxo.begin());
		}
		mx = max(mx, mndi*(2*(*maxo.begin())-mndi));
	}
	return mx;
}

Compilation message

cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:19:18: warning: comparison of integer expressions of different signedness: 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   19 |   if(maxo.size() < K || (*maxo.begin()) < O[i]) {
      |      ~~~~~~~~~~~~^~~
cross.cpp:21:19: warning: comparison of integer expressions of different signedness: 'std::multiset<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |    if(maxo.size() > K) maxo.erase(maxo.begin());
      |       ~~~~~~~~~~~~^~~
cross.cpp:17:17: warning: unused variable 'j' [-Wunused-variable]
   17 |  for(int i = 0, j = 0; i < N; i++) {
      |                 ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 280 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 280 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 1 ms 280 KB Output isn't correct
3 Halted 0 ms 0 KB -