답안 #93196

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
93196 2019-01-07T07:35:35 Z Alexa2001 Bulldozer (JOI17_bulldozer) C++17
25 / 100
2000 ms 33412 KB
#include <bits/stdc++.h>

using namespace std;

const int Nmax = 2005;
typedef long long ll;

ll ans = 0;
int n, i, j, where[Nmax], ord[Nmax];

struct point
{
    int x, y, p;
    bool operator < (const point &other) const
    {
        if(x == other.x) return y > other.y;
        return x > other.x;
    }
};
point a[Nmax];

struct intr
{
    int x, y, id1, id2;
    bool operator < (const intr &other) const
    {
        if((ll) x * other.y == (ll) y * other.x) return (make_pair(id1, id2) < make_pair(other.id1, other.id2));
        return (ll) x * other.y < (ll) y * other.x;
    }

    bool operator == (const intr &other) const
    {
        return (ll) x * other.y == (ll) y * other.x;
    }
};
vector<intr> intersect;

void apply(intr A)
{
    int p1 = where[A.id1], p2 = where[A.id2];
    assert(p1 + 1 == p2);

    swap(where[A.id1], where[A.id2]);
    swap(ord[p1], ord[p2]);
}

ll eval()
{
    ll ans = 0, s = 0;
    int i;
    for(i=1; i<=n; ++i)
    {
        int val = a[ord[i]].p;
        s = max(s, 0LL);
        s += val;
        ans = max(ans, s);
    }
    return ans;
}

int main()
{
  //  freopen("input", "r", stdin);
    cin.sync_with_stdio(false);

    cin >> n;
    for(i=1; i<=n; ++i) cin >> a[i].x >> a[i].y >> a[i].p;

    sort(a+1, a+n+1);

    for(i=1; i<=n; ++i) ord[i] = i, where[i] = i;

    for(i=1; i<=n; ++i)
        for(j=i+1; j<=n; ++j)
            if(a[i].x != a[j].x)
                intersect.push_back({a[i].y - a[j].y, a[i].x - a[j].x, i, j});

    ans = eval();
    sort(intersect.begin(), intersect.end());

    for(i=0; i<intersect.size(); ++i)
    {
        j = i;
        while(j<intersect.size() && intersect[i] == intersect[j])
            apply(intersect[j++]);
        i = j - 1;

        ans = max(ans, eval());
    }

    cout << ans << '\n';
    return 0;
}

Compilation message

bulldozer.cpp: In function 'int main()':
bulldozer.cpp:81:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=0; i<intersect.size(); ++i)
              ~^~~~~~~~~~~~~~~~~
bulldozer.cpp:84:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(j<intersect.size() && intersect[i] == intersect[j])
               ~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 560 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 560 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 2 ms 560 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 3 ms 560 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 3 ms 512 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
9 Correct 3 ms 512 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 3 ms 512 KB Output is correct
23 Correct 3 ms 512 KB Output is correct
24 Correct 3 ms 512 KB Output is correct
25 Correct 3 ms 612 KB Output is correct
26 Correct 3 ms 512 KB Output is correct
27 Correct 3 ms 512 KB Output is correct
28 Correct 3 ms 556 KB Output is correct
29 Correct 3 ms 512 KB Output is correct
30 Correct 3 ms 640 KB Output is correct
31 Correct 3 ms 612 KB Output is correct
32 Correct 3 ms 524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 3 ms 560 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 3 ms 512 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
9 Correct 3 ms 512 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 3 ms 512 KB Output is correct
23 Correct 3 ms 512 KB Output is correct
24 Correct 3 ms 512 KB Output is correct
25 Correct 3 ms 612 KB Output is correct
26 Correct 3 ms 512 KB Output is correct
27 Correct 3 ms 512 KB Output is correct
28 Correct 3 ms 556 KB Output is correct
29 Correct 3 ms 512 KB Output is correct
30 Correct 3 ms 640 KB Output is correct
31 Correct 3 ms 612 KB Output is correct
32 Correct 3 ms 524 KB Output is correct
33 Execution timed out 2025 ms 33412 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 3 ms 560 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 3 ms 512 KB Output is correct
7 Correct 3 ms 512 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
9 Correct 3 ms 512 KB Output is correct
10 Correct 3 ms 512 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 3 ms 512 KB Output is correct
23 Correct 3 ms 512 KB Output is correct
24 Correct 3 ms 512 KB Output is correct
25 Correct 3 ms 612 KB Output is correct
26 Correct 3 ms 512 KB Output is correct
27 Correct 3 ms 512 KB Output is correct
28 Correct 3 ms 556 KB Output is correct
29 Correct 3 ms 512 KB Output is correct
30 Correct 3 ms 640 KB Output is correct
31 Correct 3 ms 612 KB Output is correct
32 Correct 3 ms 524 KB Output is correct
33 Execution timed out 2025 ms 33412 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 512 KB Output is correct
3 Correct 2 ms 560 KB Output is correct
4 Correct 2 ms 640 KB Output is correct
5 Correct 2 ms 512 KB Output is correct
6 Correct 2 ms 512 KB Output is correct
7 Correct 2 ms 560 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 2 ms 560 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 3 ms 512 KB Output is correct
17 Correct 3 ms 512 KB Output is correct
18 Correct 3 ms 560 KB Output is correct
19 Correct 3 ms 512 KB Output is correct
20 Correct 3 ms 512 KB Output is correct
21 Correct 3 ms 512 KB Output is correct
22 Correct 3 ms 512 KB Output is correct
23 Correct 3 ms 512 KB Output is correct
24 Correct 3 ms 512 KB Output is correct
25 Correct 3 ms 512 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 2 ms 384 KB Output is correct
28 Correct 3 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 2 ms 384 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
33 Correct 2 ms 384 KB Output is correct
34 Correct 2 ms 384 KB Output is correct
35 Correct 2 ms 384 KB Output is correct
36 Correct 3 ms 512 KB Output is correct
37 Correct 3 ms 512 KB Output is correct
38 Correct 3 ms 512 KB Output is correct
39 Correct 3 ms 512 KB Output is correct
40 Correct 3 ms 612 KB Output is correct
41 Correct 3 ms 512 KB Output is correct
42 Correct 3 ms 512 KB Output is correct
43 Correct 3 ms 556 KB Output is correct
44 Correct 3 ms 512 KB Output is correct
45 Correct 3 ms 640 KB Output is correct
46 Correct 3 ms 612 KB Output is correct
47 Correct 3 ms 524 KB Output is correct
48 Execution timed out 2025 ms 33412 KB Time limit exceeded
49 Halted 0 ms 0 KB -