#include "cross.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld;
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
long long SelectCross(int K, std::vector<int> I, std::vector<int> O)
{
vector<ii> vec;
int n=I.size();
for(int i=0;i<n;i++)
{
vec.pb({O[i],I[i]});
}
sort(vec.begin(),vec.end());
reverse(vec.begin(),vec.end());
ll ans = 0;
pbds T;
int timer=-1;
for(int i=0;i<n;i++)
{
ll grid = vec[i].fi;
if(T.size()>=K-1)
{
ll vv = ll(1e18);
if(K-2>=0) vv=-(*T.find_by_order(K-2)).fi;
ll lowpt = min(vec[i].se, vv);
ans = max(ans, grid*grid-(grid-lowpt)*(grid-lowpt));
}
T.insert({-vec[i].se,++timer});
}
return ans;
}
Compilation message
cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:37:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(T.size()>=K-1)
~~~~~~~~^~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
256 KB |
Output is correct |
5 |
Correct |
17 ms |
1404 KB |
Output is correct |
6 |
Correct |
278 ms |
19164 KB |
Output is correct |
7 |
Correct |
330 ms |
19028 KB |
Output is correct |
8 |
Correct |
350 ms |
19164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
256 KB |
Output is correct |
5 |
Correct |
17 ms |
1404 KB |
Output is correct |
6 |
Correct |
278 ms |
19164 KB |
Output is correct |
7 |
Correct |
330 ms |
19028 KB |
Output is correct |
8 |
Correct |
350 ms |
19164 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
6 ms |
384 KB |
Output is correct |
11 |
Correct |
7 ms |
512 KB |
Output is correct |
12 |
Correct |
16 ms |
1532 KB |
Output is correct |
13 |
Correct |
142 ms |
9960 KB |
Output is correct |
14 |
Correct |
357 ms |
19168 KB |
Output is correct |
15 |
Correct |
278 ms |
19164 KB |
Output is correct |
16 |
Correct |
283 ms |
19168 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
256 KB |
Output is correct |
5 |
Correct |
17 ms |
1404 KB |
Output is correct |
6 |
Correct |
278 ms |
19164 KB |
Output is correct |
7 |
Correct |
330 ms |
19028 KB |
Output is correct |
8 |
Correct |
350 ms |
19164 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
6 ms |
384 KB |
Output is correct |
11 |
Correct |
7 ms |
512 KB |
Output is correct |
12 |
Correct |
16 ms |
1532 KB |
Output is correct |
13 |
Correct |
142 ms |
9960 KB |
Output is correct |
14 |
Correct |
357 ms |
19168 KB |
Output is correct |
15 |
Correct |
278 ms |
19164 KB |
Output is correct |
16 |
Correct |
283 ms |
19168 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
6 ms |
512 KB |
Output is correct |
19 |
Correct |
17 ms |
1660 KB |
Output is correct |
20 |
Correct |
124 ms |
9960 KB |
Output is correct |
21 |
Correct |
230 ms |
15324 KB |
Output is correct |
22 |
Correct |
295 ms |
19164 KB |
Output is correct |
23 |
Correct |
348 ms |
19164 KB |
Output is correct |
24 |
Correct |
285 ms |
19180 KB |
Output is correct |
25 |
Correct |
305 ms |
19028 KB |
Output is correct |
26 |
Correct |
289 ms |
19168 KB |
Output is correct |