# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
832431 | 2023-08-21T10:16:56 Z | _martynas | Crosses on the Grid (FXCUP4_cross) | C++17 | 115 ms | 17412 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[orderI[i]]) { maxo.insert(O[orderI[i]]); if(maxo.size() > K) maxo.erase(maxo.begin()); } if(maxo.size() == K) mx = max(mx, mndi*(2*(*maxo.begin())-mndi)); } return mx; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 232 KB | Output is correct |
5 | Correct | 3 ms | 468 KB | Output is correct |
6 | Correct | 65 ms | 4212 KB | Output is correct |
7 | Correct | 71 ms | 4268 KB | Output is correct |
8 | Correct | 56 ms | 4288 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 232 KB | Output is correct |
5 | Correct | 3 ms | 468 KB | Output is correct |
6 | Correct | 65 ms | 4212 KB | Output is correct |
7 | Correct | 71 ms | 4268 KB | Output is correct |
8 | Correct | 56 ms | 4288 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 316 KB | Output is correct |
12 | Correct | 5 ms | 768 KB | Output is correct |
13 | Correct | 40 ms | 4336 KB | Output is correct |
14 | Correct | 61 ms | 8200 KB | Output is correct |
15 | Correct | 69 ms | 8236 KB | Output is correct |
16 | Correct | 55 ms | 8096 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 232 KB | Output is correct |
5 | Correct | 3 ms | 468 KB | Output is correct |
6 | Correct | 65 ms | 4212 KB | Output is correct |
7 | Correct | 71 ms | 4268 KB | Output is correct |
8 | Correct | 56 ms | 4288 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 316 KB | Output is correct |
12 | Correct | 5 ms | 768 KB | Output is correct |
13 | Correct | 40 ms | 4336 KB | Output is correct |
14 | Correct | 61 ms | 8200 KB | Output is correct |
15 | Correct | 69 ms | 8236 KB | Output is correct |
16 | Correct | 55 ms | 8096 KB | Output is correct |
17 | Correct | 0 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 340 KB | Output is correct |
19 | Correct | 6 ms | 1364 KB | Output is correct |
20 | Correct | 30 ms | 4724 KB | Output is correct |
21 | Correct | 43 ms | 6488 KB | Output is correct |
22 | Correct | 56 ms | 8208 KB | Output is correct |
23 | Correct | 55 ms | 8112 KB | Output is correct |
24 | Correct | 68 ms | 9480 KB | Output is correct |
25 | Correct | 110 ms | 14224 KB | Output is correct |
26 | Correct | 115 ms | 17412 KB | Output is correct |