This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef complex<long long> point;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<pair<point, int>> a;
for (int i = 0; i < n; i++) {
int x, y, w;
cin >> x >> y >> w;
a.emplace_back(point(x, y), w);
}
if (n == 1) {
cout << max(0, a[0].second) << '\n';
return 0;
}
// sort(a.begin(), a.end(), [&](auto x, auto y) {
// if (x.first.real() != y.first.real()) return x.first.real() < y.first.real();
// return x.first.imag() < y.first.imag();
// });
long long ans = 0;
for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (i != j) {
point line = a[i].first - a[j].first;
vector<pair<point, int>> b = a;
sort(b.begin(), b.end(), [&](auto xw, auto yw) {
point x = xw. first, y = yw.first;
point X(line.real() * x.real() + line.imag() * x.imag(), -line.imag() * x.real() + line.real() * x.imag());
point Y(line.real() * y.real() + line.imag() * y.imag(), -line.imag() * y.real() + line.real() * y.imag());
if (X.real() != Y.real()) return X.real() < Y.real();
return X.imag() < Y.imag();
});
long long sum = 0;
long long mnsum = 0;
for (auto [p, w] : b) {
sum += w;
ans = max(ans, sum - mnsum);
mnsum = min(mnsum, sum);
}
}
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |