//雪花飄飄北風嘯嘯
//天地一片蒼茫
#include "cross.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl
#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
long long SelectCross(int k, std::vector<int> I, std::vector<int> O) {
int n = I.size();
vector<ii> v;
rep(x,0,n){
v.push_back(ii(O[x],I[x]));
}
sort(all(v));
reverse(all(v));
priority_queue<ll,vector<ll>,greater<ll> > pq;
ll ans=0;
rep(x,0,n){
pq.push(v[x].se);
if (sz(pq)>k) pq.pop();
if (sz(pq)==k){
//cout<<pq.top()<<" "<<v[x].fi<<endl;
ans=max(ans,pq.top()*v[x].fi*2-pq.top()*pq.top());
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
6 ms |
1132 KB |
Output is correct |
6 |
Correct |
94 ms |
11616 KB |
Output is correct |
7 |
Correct |
92 ms |
11620 KB |
Output is correct |
8 |
Correct |
94 ms |
11620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
6 ms |
1132 KB |
Output is correct |
6 |
Correct |
94 ms |
11616 KB |
Output is correct |
7 |
Correct |
92 ms |
11620 KB |
Output is correct |
8 |
Correct |
94 ms |
11620 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
6 ms |
1132 KB |
Output is correct |
13 |
Correct |
50 ms |
6120 KB |
Output is correct |
14 |
Correct |
94 ms |
11620 KB |
Output is correct |
15 |
Correct |
95 ms |
11620 KB |
Output is correct |
16 |
Correct |
96 ms |
11620 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
6 ms |
1132 KB |
Output is correct |
6 |
Correct |
94 ms |
11616 KB |
Output is correct |
7 |
Correct |
92 ms |
11620 KB |
Output is correct |
8 |
Correct |
94 ms |
11620 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
6 ms |
1132 KB |
Output is correct |
13 |
Correct |
50 ms |
6120 KB |
Output is correct |
14 |
Correct |
94 ms |
11620 KB |
Output is correct |
15 |
Correct |
95 ms |
11620 KB |
Output is correct |
16 |
Correct |
96 ms |
11620 KB |
Output is correct |
17 |
Correct |
1 ms |
372 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
7 ms |
1256 KB |
Output is correct |
20 |
Correct |
53 ms |
6140 KB |
Output is correct |
21 |
Correct |
75 ms |
10084 KB |
Output is correct |
22 |
Correct |
99 ms |
11620 KB |
Output is correct |
23 |
Correct |
100 ms |
11620 KB |
Output is correct |
24 |
Correct |
103 ms |
11620 KB |
Output is correct |
25 |
Correct |
104 ms |
13528 KB |
Output is correct |
26 |
Correct |
97 ms |
14168 KB |
Output is correct |