#include "cross.h"
#include <algorithm>
#include <queue>
using namespace std;
typedef long long lld;
struct cross {
lld in, ou;
bool operator< (const cross& c) const {
return ou > c.ou;
}
} ba[202020];
priority_queue<lld> pq;
lld SelectCross(int K, vector<int> I, vector<int> O) {
int N=I.size();
for(int i=0; i<N; i++) ba[i].in=I[i], ba[i].ou=O[i];
sort(ba, ba+N);
lld mx=0;
for(int i=0; i<N; i++){
pq.push(-ba[i].in);
if(i>=K) pq.pop();
if(i>=K-1){
lld ii=-pq.top(), oo=ba[i].ou;
if(mx < 2*ii*oo-ii*ii) mx = 2*ii*oo-ii*ii;
}
}
return mx;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
15 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
8 ms |
1016 KB |
Output is correct |
6 |
Correct |
101 ms |
10644 KB |
Output is correct |
7 |
Correct |
101 ms |
10584 KB |
Output is correct |
8 |
Correct |
100 ms |
10592 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
15 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
8 ms |
1016 KB |
Output is correct |
6 |
Correct |
101 ms |
10644 KB |
Output is correct |
7 |
Correct |
101 ms |
10584 KB |
Output is correct |
8 |
Correct |
100 ms |
10592 KB |
Output is correct |
9 |
Correct |
2 ms |
252 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
8 ms |
1016 KB |
Output is correct |
13 |
Correct |
53 ms |
5624 KB |
Output is correct |
14 |
Correct |
106 ms |
10576 KB |
Output is correct |
15 |
Correct |
106 ms |
10596 KB |
Output is correct |
16 |
Correct |
103 ms |
10600 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
15 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
8 ms |
1016 KB |
Output is correct |
6 |
Correct |
101 ms |
10644 KB |
Output is correct |
7 |
Correct |
101 ms |
10584 KB |
Output is correct |
8 |
Correct |
100 ms |
10592 KB |
Output is correct |
9 |
Correct |
2 ms |
252 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
8 ms |
1016 KB |
Output is correct |
13 |
Correct |
53 ms |
5624 KB |
Output is correct |
14 |
Correct |
106 ms |
10576 KB |
Output is correct |
15 |
Correct |
106 ms |
10596 KB |
Output is correct |
16 |
Correct |
103 ms |
10600 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
9 ms |
1272 KB |
Output is correct |
20 |
Correct |
57 ms |
5740 KB |
Output is correct |
21 |
Correct |
85 ms |
8552 KB |
Output is correct |
22 |
Correct |
109 ms |
10728 KB |
Output is correct |
23 |
Correct |
114 ms |
10600 KB |
Output is correct |
24 |
Correct |
111 ms |
10984 KB |
Output is correct |
25 |
Correct |
122 ms |
12672 KB |
Output is correct |
26 |
Correct |
105 ms |
12744 KB |
Output is correct |