답안 #1077854

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1077854 2024-08-27T09:47:55 Z vnm06 Bulldozer (JOI17_bulldozer) C++14
20 / 100
2000 ms 131896 KB
#include<bits/stdc++.h>
#define endl '\n'

using namespace std;

struct Point
{
    long long x, y, val, nom;
    Point() {}
    Point(long long a, long long b, long long c, long long d)
    {
        x=a;
        y=b;
        val=c;
        nom=d;
    }
};

bool operator<(Point p, Point q)
{
    if(p.x==q.x) return p.y>q.y;
    return p.x<q.x;
}

struct Line
{
    Point a, b;
    Line() {}
    Line(Point p, Point q)
    {
        a.x=p.x;
        a.y=p.y;
        a.val=p.val;
        a.nom=p.nom;
        b.x=q.x;
        b.y=q.y;
        b.val=q.val;
        b.nom=q.nom;
    }
};

bool cmp(Line p, Line q)
{
    if(p.a.x==p.b.x) return 1;
    if(q.a.x==q.b.x) return 1;
    return ((p.b.y-p.a.y) * (q.b.x-q.a.x)) < ((q.b.y-q.a.y) * (p.b.x-p.a.x));
}

long long n, brl=0;
long long pos[2005];
Point P[2005];

vector<Line> L;

long long ans=0;
long long A[2005];

void solve()
{
    long long res=0;
    for(long long i=0; i<n; i++)
    {
        res+=A[i];
        if(res<0) res=0;
        if(res>ans) ans=res;
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    for(long long i=0; i<n; i++) cin>>P[i].x>>P[i].y>>P[i].val;
    sort(P, P+n);
    for(long long i=0; i<n; i++) P[i].nom=i;
    for(long long i=0; i<n; i++)
    {
        A[i]=P[i].val;
        pos[i]=i;
        for(long long j=i+1; j<n; j++)
        {
            L.push_back(Line(P[i], P[j]));
            ///cout<<L[brl].a.x<<" "<<L[brl].a.y<<" "<<L[brl].b.x<<" "<<L[brl].b.y<<"\n";
            brl++;
        }
    }
    ///cout<<brl<<endl;
    //sort(L.begin(), L.end(), cmp);
    
    for(int i=0; i<L.size(); i++)
    {
        for(int j=0; j<L.size(); j++)
        {
            if(!cmp(L[i], L[j])) swap(L[i], L[j]);
        }
    }

    for(long long i=0; i<brl; i++)
    {
        solve();
        Point t1=L[i].a, t2=L[i].b;
        swap(A[pos[t1.nom]], A[pos[t2.nom]]);
        swap(pos[t1.nom], pos[t2.nom]);
    }
    solve();
    cout<<ans<<endl;
    return 0;
}

Compilation message

bulldozer.cpp: In function 'int main()':
bulldozer.cpp:93:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Line>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   93 |     for(int i=0; i<L.size(); i++)
      |                  ~^~~~~~~~~
bulldozer.cpp:95:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Line>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   95 |         for(int j=0; j<L.size(); j++)
      |                      ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 104 ms 988 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 988 KB Output is correct
2 Correct 53 ms 992 KB Output is correct
3 Correct 52 ms 988 KB Output is correct
4 Correct 53 ms 992 KB Output is correct
5 Correct 52 ms 992 KB Output is correct
6 Correct 55 ms 992 KB Output is correct
7 Correct 54 ms 992 KB Output is correct
8 Correct 52 ms 992 KB Output is correct
9 Correct 52 ms 988 KB Output is correct
10 Correct 55 ms 988 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 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 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 55 ms 992 KB Output is correct
22 Correct 56 ms 1248 KB Output is correct
23 Correct 54 ms 992 KB Output is correct
24 Correct 55 ms 988 KB Output is correct
25 Correct 54 ms 992 KB Output is correct
26 Correct 51 ms 992 KB Output is correct
27 Correct 59 ms 992 KB Output is correct
28 Correct 53 ms 992 KB Output is correct
29 Correct 54 ms 988 KB Output is correct
30 Correct 52 ms 988 KB Output is correct
31 Correct 53 ms 992 KB Output is correct
32 Correct 55 ms 992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 988 KB Output is correct
2 Correct 53 ms 992 KB Output is correct
3 Correct 52 ms 988 KB Output is correct
4 Correct 53 ms 992 KB Output is correct
5 Correct 52 ms 992 KB Output is correct
6 Correct 55 ms 992 KB Output is correct
7 Correct 54 ms 992 KB Output is correct
8 Correct 52 ms 992 KB Output is correct
9 Correct 52 ms 988 KB Output is correct
10 Correct 55 ms 988 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 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 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 55 ms 992 KB Output is correct
22 Correct 56 ms 1248 KB Output is correct
23 Correct 54 ms 992 KB Output is correct
24 Correct 55 ms 988 KB Output is correct
25 Correct 54 ms 992 KB Output is correct
26 Correct 51 ms 992 KB Output is correct
27 Correct 59 ms 992 KB Output is correct
28 Correct 53 ms 992 KB Output is correct
29 Correct 54 ms 988 KB Output is correct
30 Correct 52 ms 988 KB Output is correct
31 Correct 53 ms 992 KB Output is correct
32 Correct 55 ms 992 KB Output is correct
33 Execution timed out 2055 ms 131896 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 988 KB Output is correct
2 Correct 53 ms 992 KB Output is correct
3 Correct 52 ms 988 KB Output is correct
4 Correct 53 ms 992 KB Output is correct
5 Correct 52 ms 992 KB Output is correct
6 Correct 55 ms 992 KB Output is correct
7 Correct 54 ms 992 KB Output is correct
8 Correct 52 ms 992 KB Output is correct
9 Correct 52 ms 988 KB Output is correct
10 Correct 55 ms 988 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 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 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 55 ms 992 KB Output is correct
22 Correct 56 ms 1248 KB Output is correct
23 Correct 54 ms 992 KB Output is correct
24 Correct 55 ms 988 KB Output is correct
25 Correct 54 ms 992 KB Output is correct
26 Correct 51 ms 992 KB Output is correct
27 Correct 59 ms 992 KB Output is correct
28 Correct 53 ms 992 KB Output is correct
29 Correct 54 ms 988 KB Output is correct
30 Correct 52 ms 988 KB Output is correct
31 Correct 53 ms 992 KB Output is correct
32 Correct 55 ms 992 KB Output is correct
33 Execution timed out 2055 ms 131896 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 104 ms 988 KB Output isn't correct
2 Halted 0 ms 0 KB -