Submission #234127

# Submission time Handle Problem Language Result Execution time Memory
234127 2020-05-23T08:43:30 Z RiscadoA Bulldozer (JOI17_bulldozer) C++14
0 / 100
5 ms 384 KB
#include <bits/stdc++.h>

using namespace std;

struct Point {
    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;
    
    sort(P.begin(), P.end(), [](const Point& lhs, const Point& rhs) -> bool {
        return lhs.x < rhs.x;
    });

    for (int64_t i = 0, sum = 0; i < N; ++i) {
        if (P[i].w > P[i].w + sum) {
            sum = P[i].w;
        } else {
            sum += P[i].w;
        }

        max_sum = max(max_sum, sum);
    }

    sort(P.begin(), P.end(), [](const Point& lhs, const Point& rhs) -> bool {
        return lhs.y < rhs.y;
    });

    for (int64_t i = 0, sum = 0; i < N; ++i) {
        if (P[i].w > P[i].w + sum) {
            sum = P[i].w;
        } else {
            sum += P[i].w;
        }

        max_sum = max(max_sum, sum);
    }

    cout << max_sum << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 4 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -