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;
struct Point {
double pos;
int64_t x, y, w;
};
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int N;
vector<Point> P;
cin >> N;
P.resize(N);
for (int i = 0; i < N; ++i) {
cin >> P[i].x >> P[i].y >> P[i].w;
}
int64_t max_sum = 0;
// For each axis
for (int i = 0; i < N - 1; ++i) {
for (int j = i + 1; j < N; ++j) {
// Get line equation
auto a = -1.0 / double(P[i].y - P[j].y);
auto b = 1.0 / double(P[j].x - P[i].x);
if (a == INFINITY || a == -INFINITY) {
a = 1.0f;
b = 0.0f;
} else if (b == INFINITY || b == -INFINITY) {
a = 0.0f;
b = 1.0f;
}
for (auto& p : P) {
p.pos = double(a * p.x + b * p.y) / (a * a + b * b);
}
sort(P.begin(), P.end(), [](const Point& lhs, const Point& rhs) -> bool {
return lhs.pos < rhs.pos;
});
for (int64_t i = 0, sum = 0; i < N;) {
double pos = P[i].pos;
int64_t w = 0;
while (abs(P[i].pos - pos) < 0.001 && i < N) {
w += P[i].w;
++i;
}
if (sum <= 0) {
sum = w;
} else {
sum += w;
}
max_sum = max(max_sum, sum);
}
}
}
cout << max_sum << endl;
}
# | 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... |