Submission #234136

#TimeUsernameProblemLanguageResultExecution timeMemory
234136RiscadoABulldozer (JOI17_bulldozer)C++14
0 / 100
28 ms384 KiB
#include <bits/stdc++.h> using namespace std; struct Point { double pos; int64_t x, y, w; }; int main() { //freopen("in.txt", "r", stdin); 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) { double ux = P[j].x - P[i].x; double uy = P[j].y - P[i].y; for (auto& p : P) { p.pos = double(uy * p.x - ux * p.y + P[j].x * P[i].y - P[j].y * P[i].x) / (ux * ux + uy * uy); } 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.0001 && 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...