#include "squad.h"
#include<bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using vi = vector<ll>;
int n;
vi a, d, p;
using vec = complex<ll>;
ll dot(vec a, vec b) {
return (conj(a)*b).real();
}
ll cross(vec a, vec b) {
return (conj(a)*b).imag();
}
vector<vec> v;
void Init(std::vector<int> xA, std::vector<int> xD, std::vector<int> xP){
n = xA.size();
for(auto i : xA) a.pb(i);
for(auto i : xD) d.pb(i);
for(auto i : xP) p.pb(i);
vector<vec> t;
for(int i = 0; i < n; i++)
t.pb(vec(a[i], p[i]));
sort(all(t), [](const vec &a, const vec &b) {
return cross(a, b) < 0;
});
int i, j;
i = j = 0;
while(i < t.size()) {
vec c(0, 0);
while(j < t.size() && cross(t[i], t[j]) == 0) {
if(norm(c) < norm(t[j]))
c = t[j];
j++;
}
v.pb(c);
i = j;
}
sort(all(p));
}
long long BestSquad(int X, int Y){
ll ans = 0;
auto it = upper_bound(all(v), vec(X, Y), [](const vec &a, const vec &b) {
return cross(a, b) < 0;
});
if(it != v.end()) {
ll t = X+dot(*it, vec(X, Y));
if(it->imag() == p[0])
t += Y*1ll*p[1];
else
t += Y*1ll*p[0];
ans = max(ans, t);
}
if(it != v.begin()) {
--it;
ll t = X+dot(*it, vec(X, Y));
if(it->imag() == p[0])
t += Y*1ll*p[1];
else
t += Y*1ll*p[0];
ans = max(ans, t);
}
return ans;
}
Compilation message
squad.cpp: In function 'void Init(std::vector<int>, std::vector<int>, std::vector<int>)':
squad.cpp:33:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(i < t.size()) {
~~^~~~~~~~~~
squad.cpp:35:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(j < t.size() && cross(t[i], t[j]) == 0) {
~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |