Submission #832541

# Submission time Handle Problem Language Result Execution time Memory
832541 2023-08-21T11:24:35 Z Liudas Crosses on the Grid (FXCUP4_cross) C++17
100 / 100
73 ms 11932 KB
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
using namespace std;
struct cross{
    int i, o;
    long long s;
};
long long SelectCross(int K, vector<int> I, vector<int> O){
    int N = I.size();
    vector<cross> arr(N);
    for(int i = 0; i < N;  i++){
        arr[i] = {I[i], O[i], 1ll * I[i] * O[i] * 2 - 1ll * I[i] * I[i]};
    }
    sort(arr.begin(), arr.end(), [](cross a, cross b){return make_pair(a.i, a.o) > make_pair(b.i, b.o);});
    priority_queue<int, vector<int>, greater<int>> que;
    for(int i = 0; i < K-1; i ++){
        que.push(arr[i].o);
    }
    long long ans = 0;
    for(int i = K-1; i < N; i ++){
        que.push(arr[i].o);
        int a = que.top();
        que.pop();
        ans = max(ans, 1ll * arr[i].i * a * 2 - 1ll * arr[i].i * arr[i].i);
    }
    return ans;
}
# 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 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 4 ms 852 KB Output is correct
6 Correct 57 ms 10536 KB Output is correct
7 Correct 56 ms 10476 KB Output is correct
8 Correct 56 ms 10440 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 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 4 ms 852 KB Output is correct
6 Correct 57 ms 10536 KB Output is correct
7 Correct 56 ms 10476 KB Output is correct
8 Correct 56 ms 10440 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 4 ms 904 KB Output is correct
13 Correct 29 ms 5584 KB Output is correct
14 Correct 66 ms 10488 KB Output is correct
15 Correct 59 ms 10504 KB Output is correct
16 Correct 59 ms 10440 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 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 4 ms 852 KB Output is correct
6 Correct 57 ms 10536 KB Output is correct
7 Correct 56 ms 10476 KB Output is correct
8 Correct 56 ms 10440 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 4 ms 904 KB Output is correct
13 Correct 29 ms 5584 KB Output is correct
14 Correct 66 ms 10488 KB Output is correct
15 Correct 59 ms 10504 KB Output is correct
16 Correct 59 ms 10440 KB Output is correct
17 Correct 1 ms 296 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 4 ms 980 KB Output is correct
20 Correct 32 ms 5484 KB Output is correct
21 Correct 49 ms 8436 KB Output is correct
22 Correct 65 ms 10436 KB Output is correct
23 Correct 73 ms 10544 KB Output is correct
24 Correct 67 ms 10616 KB Output is correct
25 Correct 64 ms 11932 KB Output is correct
26 Correct 61 ms 11828 KB Output is correct