#include "cross.h"
#include <bits/stdc++.h>
using namespace std;
#define pii pair<long long,long long>
#define F first
#define S second
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
// order_of_key
typedef tree<
pair<int, int>,
null_type,
less<pair<ll, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
ordered_set X;
long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
vector<pii> v(I.size());
for(int i = 0 ; i < I.size() ; i ++){
v.push_back(pii(O[i] , I[i]));
}
sort(v.rbegin() , v.rend());
ll ans = 0;
for(int i = 0 ; i < I.size() ; i ++){
X.insert(pii(-v[i].second, i));
if(X.size() >= K){
pii R = *X.find_by_order(K-1);
R.first *= -1;
R.first = min(R.first , v[i].second);
// cout<<v[i].first * v[i].first<<" " << -2*(v[i].first - R.first) << endl;
ans = max(ans ,v[i].first * v[i].first - 2LL*(v[i].first - R.first));
}
// cout<<v[i].first<<" "<<v[i].second<<endl;
}
return ans;
}
Compilation message
cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:25:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0 ; i < I.size() ; i ++){
~~^~~~~~~~~~
cross.cpp:30:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0 ; i < I.size() ; i ++){
~~^~~~~~~~~~
cross.cpp:32:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(X.size() >= K){
~~~~~~~~~^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |