#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];
lld ent[202020], cnt;
lld SelectCross(int N, int K, vector<int> I, vector<int> O) {
for(int i=0; i<N; i++) ba[i].in=I[i], ba[i].ou=O[i];
sort(ba, ba+N);
lld mx=0; cnt=0;
for(int i=0; i<N; i++){
ent[cnt++]=-ba[i].in; sort(ent, ent+cnt);
if(i>=K) cnt--;
if(i>=K-1){
lld ii=-ent[cnt-1], oo=ba[i].ou;
if(mx < 2*ii*oo-ii*ii) mx = 2*ii*oo-ii*ii;
}
}
return mx;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
7 ms |
716 KB |
Output is correct |
6 |
Correct |
85 ms |
6760 KB |
Output is correct |
7 |
Correct |
86 ms |
6632 KB |
Output is correct |
8 |
Correct |
84 ms |
6760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
7 ms |
716 KB |
Output is correct |
6 |
Correct |
85 ms |
6760 KB |
Output is correct |
7 |
Correct |
86 ms |
6632 KB |
Output is correct |
8 |
Correct |
84 ms |
6760 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
4 ms |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
7 ms |
768 KB |
Output is correct |
13 |
Correct |
52 ms |
3636 KB |
Output is correct |
14 |
Correct |
85 ms |
6760 KB |
Output is correct |
15 |
Correct |
94 ms |
6760 KB |
Output is correct |
16 |
Correct |
95 ms |
6636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
7 ms |
716 KB |
Output is correct |
6 |
Correct |
85 ms |
6760 KB |
Output is correct |
7 |
Correct |
86 ms |
6632 KB |
Output is correct |
8 |
Correct |
84 ms |
6760 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
4 ms |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
7 ms |
768 KB |
Output is correct |
13 |
Correct |
52 ms |
3636 KB |
Output is correct |
14 |
Correct |
85 ms |
6760 KB |
Output is correct |
15 |
Correct |
94 ms |
6760 KB |
Output is correct |
16 |
Correct |
95 ms |
6636 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
12 ms |
384 KB |
Output is correct |
19 |
Execution timed out |
1072 ms |
1080 KB |
Time limit exceeded |
20 |
Halted |
0 ms |
0 KB |
- |