Submission #927334

# Submission time Handle Problem Language Result Execution time Memory
927334 2024-02-14T18:23:47 Z DAleksa Bulldozer (JOI17_bulldozer) C++17
20 / 100
469 ms 1048 KB
#include <bits/stdc++.h>

using namespace std;

struct point {
    int x;
    int y;
    int w;
};

struct frac {
    int p;
    int q;
    frac() { }
    frac(int _p, int _q) { p = _p; q = _q; }
};

bool operator < (frac a, frac b) {
    return a.p * 1LL * b.q < b.p * 1LL * a.q;
}

const int N = 105;
int n;
point a[N];
map<frac, vector<pair<int, int>>> buc;
vector<frac> slopes;
int order[N], pos[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i].x >> a[i].y >> a[i].w;
    for(int i = 1; i <= n; i++) {
        for(int j = i + 1; j <= n; j++) {
            int sign = 1;
            int dx = a[i].x - a[j].x, dy = a[i].y - a[j].y;
            if(dx < 0) sign *= -1;
            if(dy < 0) sign *= -1;
            dx = abs(dx);
            dy = abs(dy);
            int g = __gcd(dx, dy);
            dx /= g;
            dy /= g;
            if(dx != 0) dy *= sign;
            if(a[i].x == a[j].x) {
                if(a[i].y > a[j].y) buc[frac(dy, dx)].emplace_back(i, j);
                else buc[frac(dy, dx)].emplace_back(j, i);
            } else {
                if(a[i].x < a[j].x) buc[frac(dy, dx)].emplace_back(i, j);
                else buc[frac(dy, dx)].emplace_back(j, i);
            }
            slopes.push_back(frac(dy, dx));
        }
    }
    sort(slopes.begin(), slopes.end(), [&](frac a, frac b) {
        return a.p * 1LL * b.q < b.p * 1LL * a.q;
    });
    for(int i = 1; i <= n; i++) order[i] = i;
    sort(order + 1, order + n + 1, [&](int i, int j) {
        if(a[i].x == a[j].x) return a[i].y > a[j].y;
        return a[i].x < a[j].x;
    });
    for(int i = 1; i <= n; i++) pos[order[i]] = i;
    long long ans = 0;
    for(frac slope : slopes) {
        long long mx = 0;
        for(int i = 1; i <= n; i++) {
            mx = max((long long)a[order[i]].w, a[order[i]].w + mx);
            ans = max(ans, mx);
        }
        sort(buc[slope].begin(), buc[slope].end());
        for(pair<int, int> p : buc[slope]) {
            int i = p.first, j = p.second;
            if(pos[i] < pos[j]) {
                swap(order[pos[i]], order[pos[j]]);
                swap(pos[i], pos[j]);
            }
        }
    }
    {
        long long mx = 0;
        for(int i = 1; i <= n; i++) {
            mx = max((long long)a[order[i]].w, a[order[i]].w + mx);
            ans = max(ans, mx);
        }
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 469 ms 616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 860 KB Output is correct
2 Correct 4 ms 860 KB Output is correct
3 Correct 4 ms 860 KB Output is correct
4 Correct 4 ms 860 KB Output is correct
5 Correct 4 ms 860 KB Output is correct
6 Correct 4 ms 860 KB Output is correct
7 Correct 4 ms 860 KB Output is correct
8 Correct 4 ms 1040 KB Output is correct
9 Correct 4 ms 860 KB Output is correct
10 Correct 4 ms 1048 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 3 ms 860 KB Output is correct
22 Correct 3 ms 860 KB Output is correct
23 Correct 4 ms 860 KB Output is correct
24 Correct 4 ms 856 KB Output is correct
25 Correct 3 ms 860 KB Output is correct
26 Correct 3 ms 860 KB Output is correct
27 Correct 3 ms 860 KB Output is correct
28 Correct 3 ms 860 KB Output is correct
29 Correct 3 ms 860 KB Output is correct
30 Correct 3 ms 860 KB Output is correct
31 Correct 3 ms 860 KB Output is correct
32 Correct 3 ms 856 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 860 KB Output is correct
2 Correct 4 ms 860 KB Output is correct
3 Correct 4 ms 860 KB Output is correct
4 Correct 4 ms 860 KB Output is correct
5 Correct 4 ms 860 KB Output is correct
6 Correct 4 ms 860 KB Output is correct
7 Correct 4 ms 860 KB Output is correct
8 Correct 4 ms 1040 KB Output is correct
9 Correct 4 ms 860 KB Output is correct
10 Correct 4 ms 1048 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 3 ms 860 KB Output is correct
22 Correct 3 ms 860 KB Output is correct
23 Correct 4 ms 860 KB Output is correct
24 Correct 4 ms 856 KB Output is correct
25 Correct 3 ms 860 KB Output is correct
26 Correct 3 ms 860 KB Output is correct
27 Correct 3 ms 860 KB Output is correct
28 Correct 3 ms 860 KB Output is correct
29 Correct 3 ms 860 KB Output is correct
30 Correct 3 ms 860 KB Output is correct
31 Correct 3 ms 860 KB Output is correct
32 Correct 3 ms 856 KB Output is correct
33 Runtime error 1 ms 604 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 860 KB Output is correct
2 Correct 4 ms 860 KB Output is correct
3 Correct 4 ms 860 KB Output is correct
4 Correct 4 ms 860 KB Output is correct
5 Correct 4 ms 860 KB Output is correct
6 Correct 4 ms 860 KB Output is correct
7 Correct 4 ms 860 KB Output is correct
8 Correct 4 ms 1040 KB Output is correct
9 Correct 4 ms 860 KB Output is correct
10 Correct 4 ms 1048 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 3 ms 860 KB Output is correct
22 Correct 3 ms 860 KB Output is correct
23 Correct 4 ms 860 KB Output is correct
24 Correct 4 ms 856 KB Output is correct
25 Correct 3 ms 860 KB Output is correct
26 Correct 3 ms 860 KB Output is correct
27 Correct 3 ms 860 KB Output is correct
28 Correct 3 ms 860 KB Output is correct
29 Correct 3 ms 860 KB Output is correct
30 Correct 3 ms 860 KB Output is correct
31 Correct 3 ms 860 KB Output is correct
32 Correct 3 ms 856 KB Output is correct
33 Runtime error 1 ms 604 KB Execution killed with signal 11
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 469 ms 616 KB Output isn't correct
2 Halted 0 ms 0 KB -