Submission #1077782

# Submission time Handle Problem Language Result Execution time Memory
1077782 2024-08-27T09:07:28 Z danikoynov Bulldozer (JOI17_bulldozer) C++14
0 / 100
37 ms 548 KB
#include<bits/stdc++.h>
#define endl '\n'

using namespace std;
typedef long long ll;

struct Point
{
    long double x, y;

    Point(long double _x = 0, long double _y = 0)
    {
        x = _x;
        y = _y;
    }

    void input()
    {
        cin >> x >> y;
    }
};

const int MAXN = 2010;
int n;
pair < Point, ll > spot[MAXN];
void input()
{
    cin >> n;
    for (int i = 1; i <= n; i ++)
    {
        spot[i].first.input();
        cin >> spot[i].second;
    }
}

long double signed_area(Point A, Point B, Point C) /// returns signed area * 2
{
    long double area = (B.x - A.x) * (A.y + B.y) +
                (C.x - B.x) * (B.y + C.y) +
                    (A.x - C.x) * (C.y + A.y);
    return area;
}

int orient(Point A, Point B, Point C)
{

    long double area = signed_area(A, B, C);

    if (area > 0)
        return 1;
    if (area < 0)
        return -1;
    assert(area != 0);
    return 0;
}

void simulate()
{
    ll result = 0;
    for (int i = 1; i <= n; i ++)
        for (int j = i + 1; j <= n; j ++)
        {
            vector < pair < long double, ll > > pos, neg;
            for (int k = 1; k <= n; k ++)
            {
                if (k == i || k == j)
                    continue;
                long double area = signed_area(spot[i].first, 
                                        spot[j].first, 
                                        spot[k].first);
                /**if (i == 3 && j == 4)
                {
                    cout << "pair with " << k << " area " << area << " value " << spot[k].second << endl;
                }*/
                if (area > 0)
                    pos.push_back({area, spot[k].second});
                else
                    neg.push_back({-area, spot[k].second});
                
            }

            sort(pos.begin(), pos.end());
            sort(neg.begin(), neg.end());

            ll best = 0, sum = 0;
            for (pair < long double, ll > cur : pos)
            {
                sum += cur.second;
                best = max(best, sum);
            }

            sum = 0;
            for (pair < long double, ll > cur : neg)
            {
                sum += cur.second;
                best = max(best, sum);
            }
            //cout << "HERE " << best << endl;
            best = best + spot[i].second;
            best = best + spot[j].second;
            //cout << "new best " << best << endl;
            ll mx = min(spot[i].second, spot[j].second);
            //cout << "mx " << mx << endl;
            if (mx < 0)
                best -= mx;
            //cout << "pair " << i << " " << j << " " << best << endl;
            result = max(result, best);

        }

    cout << result << endl;
}
void solve()
{
    input();
    simulate();
}
int main()
{
    solve();
    return 0;
}
/*
3
0 0 1
1 0 1
2 0 1
*/
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 36 ms 348 KB Output is correct
2 Correct 37 ms 348 KB Output is correct
3 Correct 36 ms 528 KB Output is correct
4 Correct 37 ms 348 KB Output is correct
5 Correct 36 ms 348 KB Output is correct
6 Correct 36 ms 344 KB Output is correct
7 Correct 36 ms 544 KB Output is correct
8 Correct 36 ms 348 KB Output is correct
9 Correct 36 ms 548 KB Output is correct
10 Correct 37 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 36 ms 348 KB Output is correct
2 Correct 37 ms 348 KB Output is correct
3 Correct 36 ms 528 KB Output is correct
4 Correct 37 ms 348 KB Output is correct
5 Correct 36 ms 348 KB Output is correct
6 Correct 36 ms 344 KB Output is correct
7 Correct 36 ms 544 KB Output is correct
8 Correct 36 ms 348 KB Output is correct
9 Correct 36 ms 548 KB Output is correct
10 Correct 37 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 36 ms 348 KB Output is correct
2 Correct 37 ms 348 KB Output is correct
3 Correct 36 ms 528 KB Output is correct
4 Correct 37 ms 348 KB Output is correct
5 Correct 36 ms 348 KB Output is correct
6 Correct 36 ms 344 KB Output is correct
7 Correct 36 ms 544 KB Output is correct
8 Correct 36 ms 348 KB Output is correct
9 Correct 36 ms 548 KB Output is correct
10 Correct 37 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -