Submission #234162

# Submission time Handle Problem Language Result Execution time Memory
234162 2020-05-23T12:34:29 Z RiscadoA Bulldozer (JOI17_bulldozer) C++14
0 / 100
31 ms 512 KB
#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
1 Correct 13 ms 256 KB Output is correct
2 Correct 14 ms 384 KB Output is correct
3 Correct 19 ms 384 KB Output is correct
4 Correct 12 ms 384 KB Output is correct
5 Correct 13 ms 384 KB Output is correct
6 Correct 13 ms 384 KB Output is correct
7 Correct 12 ms 384 KB Output is correct
8 Correct 13 ms 384 KB Output is correct
9 Correct 14 ms 384 KB Output is correct
10 Correct 14 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Incorrect 5 ms 384 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 384 KB Output is correct
2 Correct 28 ms 384 KB Output is correct
3 Correct 27 ms 384 KB Output is correct
4 Correct 31 ms 384 KB Output is correct
5 Correct 29 ms 384 KB Output is correct
6 Correct 27 ms 384 KB Output is correct
7 Correct 28 ms 512 KB Output is correct
8 Incorrect 27 ms 396 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 384 KB Output is correct
2 Correct 28 ms 384 KB Output is correct
3 Correct 27 ms 384 KB Output is correct
4 Correct 31 ms 384 KB Output is correct
5 Correct 29 ms 384 KB Output is correct
6 Correct 27 ms 384 KB Output is correct
7 Correct 28 ms 512 KB Output is correct
8 Incorrect 27 ms 396 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 28 ms 384 KB Output is correct
2 Correct 28 ms 384 KB Output is correct
3 Correct 27 ms 384 KB Output is correct
4 Correct 31 ms 384 KB Output is correct
5 Correct 29 ms 384 KB Output is correct
6 Correct 27 ms 384 KB Output is correct
7 Correct 28 ms 512 KB Output is correct
8 Incorrect 27 ms 396 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 256 KB Output is correct
2 Correct 14 ms 384 KB Output is correct
3 Correct 19 ms 384 KB Output is correct
4 Correct 12 ms 384 KB Output is correct
5 Correct 13 ms 384 KB Output is correct
6 Correct 13 ms 384 KB Output is correct
7 Correct 12 ms 384 KB Output is correct
8 Correct 13 ms 384 KB Output is correct
9 Correct 14 ms 384 KB Output is correct
10 Correct 14 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Incorrect 5 ms 384 KB Output isn't correct
13 Halted 0 ms 0 KB -