Submission #764272

# Submission time Handle Problem Language Result Execution time Memory
764272 2023-06-23T09:50:03 Z idkhandle Crosses on the Grid (FXCUP4_cross) C++17
100 / 100
106 ms 18152 KB
#include "cross.h"
#include <bits/stdc++.h>
using namespace std;

using pii = pair<int, int>;
using ll = long long;

const int INF = 1e9;

ll SelectCross(int K, vector<int> I, vector<int> O) {
	int n = I.size();
	vector<pii> a;
	for (int i = 0; i < n; i++) {
		a.emplace_back(I[i], O[i]);
	}
	sort(a.begin(), a.end());

	multiset<int> st;
	ll ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (st.size() >= K - 1) {
			ans = max(ans, a[i].first * (2LL * min((K == 1 ? INF : *st.begin()), a[i].second) - a[i].first));
			st.insert(a[i].second);
			st.erase(st.begin());
		}
		else {
			st.insert(a[i].second);
		}
	}
	return ans;
}

Compilation message

cross.cpp: In function 'll SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:21:17: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |   if (st.size() >= K - 1) {
      |       ~~~~~~~~~~^~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 4 ms 724 KB Output is correct
6 Correct 56 ms 5620 KB Output is correct
7 Correct 61 ms 5532 KB Output is correct
8 Correct 57 ms 5576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 4 ms 724 KB Output is correct
6 Correct 56 ms 5620 KB Output is correct
7 Correct 61 ms 5532 KB Output is correct
8 Correct 57 ms 5576 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 4 ms 764 KB Output is correct
13 Correct 32 ms 3148 KB Output is correct
14 Correct 57 ms 5704 KB Output is correct
15 Correct 58 ms 5696 KB Output is correct
16 Correct 64 ms 5860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 4 ms 724 KB Output is correct
6 Correct 56 ms 5620 KB Output is correct
7 Correct 61 ms 5532 KB Output is correct
8 Correct 57 ms 5576 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 316 KB Output is correct
12 Correct 4 ms 764 KB Output is correct
13 Correct 32 ms 3148 KB Output is correct
14 Correct 57 ms 5704 KB Output is correct
15 Correct 58 ms 5696 KB Output is correct
16 Correct 64 ms 5860 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 6 ms 1224 KB Output is correct
20 Correct 32 ms 3208 KB Output is correct
21 Correct 45 ms 8016 KB Output is correct
22 Correct 62 ms 9388 KB Output is correct
23 Correct 60 ms 9476 KB Output is correct
24 Correct 69 ms 10208 KB Output is correct
25 Correct 91 ms 15008 KB Output is correct
26 Correct 106 ms 18152 KB Output is correct