답안 #104164

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
104164 2019-04-04T09:09:34 Z Bodo171 Bulldozer (JOI17_bulldozer) C++14
100 / 100
1229 ms 47608 KB
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
const int nmax=2005;
struct point
{
    long long x,y,val;
}v[nmax];
struct line
{
    long long nr,nm;
    int i1,i2;
}pp[nmax*nmax/2];
struct node
{
    long long mxsuf,mxpref,sum,mx;
}arb[4*nmax],ans;
bool compP(point unu,point doi)
{
    if(unu.x==doi.x) return unu.y>doi.y;
    return (unu.x>doi.x);
}
bool compL(line unu,line doi)
{
    if((1LL*unu.nr*doi.nm==1LL*unu.nm*doi.nr))
    {
        if(unu.i1==doi.i1) return unu.i2<doi.i2;
        return unu.i1<doi.i1;
    }
    return (1LL*unu.nr*doi.nm<1LL*unu.nm*doi.nr);
}
int ord[nmax];
long long A[nmax];
int n,i,j,nr,I,J,poz;
long long act,mx;
void mrg(node &A,node B,node C)
{
    A.sum=1LL*B.sum+C.sum;
    A.mxpref=max(B.mxpref,B.sum+C.mxpref);
    A.mxsuf=max(C.mxsuf,C.sum+B.mxsuf);
    A.mx=max(B.mx,C.mx);
    A.mx=max(A.mx,B.mxsuf+C.mxpref);
}
void update(int nod,int l,int r,int poz,long long val)
{
    if(l==r)
    {
        arb[nod].mx=max(val,0LL);
        arb[nod].mxpref=arb[nod].mxsuf=max(val,0LL);
        arb[nod].sum=val;
        return;
    }
    int m=(l+r)/2;
    if(poz<=m) update(2*nod,l,m,poz,val);
    else update(2*nod+1,m+1,r,poz,val);
    mrg(arb[nod],arb[2*nod],arb[2*nod+1]);
}
int abss(int x)
{
    if(x<0) return -x;
    return x;
}
int main()
{
    //freopen("data.in","r",stdin);
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>v[i].x>>v[i].y>>v[i].val;
    }
    sort(v+1,v+n+1,compP);
    for(i=1;i<=n;i++)
    {
        ord[i]=i;
        update(1,1,n,i,v[i].val);
    }
    for(i=1;i<=n;i++)
        for(j=i+1;j<=n;j++)
            if(v[i].x!=v[j].x)
    {
        pp[++nr]={v[j].y-v[i].y,v[j].x-v[i].x,i,j};
        if(pp[nr].nm<0)
            pp[nr].nr*=-1,pp[nr].nm*=-1;
    }
    mx=arb[1].mx;
    sort(pp+1,pp+nr+1,compL);
    int lim;
    for(i=1;i<=nr;i++)
    {
         for(j=i;j<=nr&&1LL*pp[i].nm*pp[j].nr==1LL*pp[i].nr*pp[j].nm;j++);
        j--;
        lim=j;
        for(j=i;j<=lim;j++)
        {
            I=pp[j].i1;
            J=pp[j].i2;
            swap(ord[I],ord[J]);
            poz=min(ord[I],ord[J]);
            update(1,1,n,ord[I],v[I].val);
            update(1,1,n,ord[J],v[J].val);
        }
        mx=max(mx,arb[1].mx);
        i=lim;
    }
    cout<<mx;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 3 ms 512 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 4 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 4 ms 512 KB Output is correct
9 Correct 3 ms 512 KB Output is correct
10 Correct 3 ms 556 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 512 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 4 ms 512 KB Output is correct
8 Correct 4 ms 512 KB Output is correct
9 Correct 4 ms 512 KB Output is correct
10 Correct 4 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 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 1 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 4 ms 512 KB Output is correct
25 Correct 4 ms 512 KB Output is correct
26 Correct 3 ms 512 KB Output is correct
27 Correct 4 ms 512 KB Output is correct
28 Correct 3 ms 512 KB Output is correct
29 Correct 4 ms 512 KB Output is correct
30 Correct 3 ms 512 KB Output is correct
31 Correct 4 ms 512 KB Output is correct
32 Correct 3 ms 512 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 512 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 4 ms 512 KB Output is correct
8 Correct 4 ms 512 KB Output is correct
9 Correct 4 ms 512 KB Output is correct
10 Correct 4 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 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 1 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 4 ms 512 KB Output is correct
25 Correct 4 ms 512 KB Output is correct
26 Correct 3 ms 512 KB Output is correct
27 Correct 4 ms 512 KB Output is correct
28 Correct 3 ms 512 KB Output is correct
29 Correct 4 ms 512 KB Output is correct
30 Correct 3 ms 512 KB Output is correct
31 Correct 4 ms 512 KB Output is correct
32 Correct 3 ms 512 KB Output is correct
33 Correct 1064 ms 47500 KB Output is correct
34 Correct 1080 ms 47504 KB Output is correct
35 Correct 1080 ms 47500 KB Output is correct
36 Correct 1071 ms 47492 KB Output is correct
37 Correct 1057 ms 47500 KB Output is correct
38 Correct 1049 ms 47608 KB Output is correct
39 Correct 1060 ms 47496 KB Output is correct
40 Correct 1073 ms 47492 KB Output is correct
41 Correct 1061 ms 47492 KB Output is correct
42 Correct 1075 ms 47496 KB Output is correct
43 Correct 1065 ms 47500 KB Output is correct
44 Correct 1072 ms 47492 KB Output is correct
45 Correct 1093 ms 47500 KB Output is correct
46 Correct 1109 ms 47508 KB Output is correct
47 Correct 1097 ms 47492 KB Output is correct
48 Correct 1119 ms 47492 KB Output is correct
49 Correct 1079 ms 47480 KB Output is correct
50 Correct 1077 ms 47496 KB Output is correct
51 Correct 1053 ms 47496 KB Output is correct
52 Correct 1050 ms 47496 KB Output is correct
53 Correct 1059 ms 47504 KB Output is correct
54 Correct 1069 ms 47580 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 512 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 3 ms 512 KB Output is correct
6 Correct 4 ms 512 KB Output is correct
7 Correct 4 ms 512 KB Output is correct
8 Correct 4 ms 512 KB Output is correct
9 Correct 4 ms 512 KB Output is correct
10 Correct 4 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 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 1 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 4 ms 512 KB Output is correct
25 Correct 4 ms 512 KB Output is correct
26 Correct 3 ms 512 KB Output is correct
27 Correct 4 ms 512 KB Output is correct
28 Correct 3 ms 512 KB Output is correct
29 Correct 4 ms 512 KB Output is correct
30 Correct 3 ms 512 KB Output is correct
31 Correct 4 ms 512 KB Output is correct
32 Correct 3 ms 512 KB Output is correct
33 Correct 1064 ms 47500 KB Output is correct
34 Correct 1080 ms 47504 KB Output is correct
35 Correct 1080 ms 47500 KB Output is correct
36 Correct 1071 ms 47492 KB Output is correct
37 Correct 1057 ms 47500 KB Output is correct
38 Correct 1049 ms 47608 KB Output is correct
39 Correct 1060 ms 47496 KB Output is correct
40 Correct 1073 ms 47492 KB Output is correct
41 Correct 1061 ms 47492 KB Output is correct
42 Correct 1075 ms 47496 KB Output is correct
43 Correct 1065 ms 47500 KB Output is correct
44 Correct 1072 ms 47492 KB Output is correct
45 Correct 1093 ms 47500 KB Output is correct
46 Correct 1109 ms 47508 KB Output is correct
47 Correct 1097 ms 47492 KB Output is correct
48 Correct 1119 ms 47492 KB Output is correct
49 Correct 1079 ms 47480 KB Output is correct
50 Correct 1077 ms 47496 KB Output is correct
51 Correct 1053 ms 47496 KB Output is correct
52 Correct 1050 ms 47496 KB Output is correct
53 Correct 1059 ms 47504 KB Output is correct
54 Correct 1069 ms 47580 KB Output is correct
55 Correct 1054 ms 47496 KB Output is correct
56 Correct 1069 ms 47504 KB Output is correct
57 Correct 1155 ms 47508 KB Output is correct
58 Correct 1056 ms 47492 KB Output is correct
59 Correct 1068 ms 47508 KB Output is correct
60 Correct 1075 ms 47496 KB Output is correct
61 Correct 1078 ms 47504 KB Output is correct
62 Correct 1229 ms 47492 KB Output is correct
63 Correct 1087 ms 47492 KB Output is correct
64 Correct 1078 ms 47496 KB Output is correct
65 Correct 1094 ms 47468 KB Output is correct
66 Correct 1123 ms 47472 KB Output is correct
67 Correct 1067 ms 47468 KB Output is correct
68 Correct 1072 ms 47468 KB Output is correct
69 Correct 1059 ms 47480 KB Output is correct
70 Correct 1079 ms 47472 KB Output is correct
71 Correct 1082 ms 47480 KB Output is correct
72 Correct 1098 ms 47468 KB Output is correct
73 Correct 1107 ms 47476 KB Output is correct
74 Correct 1077 ms 47476 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 512 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 4 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 4 ms 512 KB Output is correct
9 Correct 3 ms 512 KB Output is correct
10 Correct 3 ms 556 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 512 KB Output is correct
19 Correct 3 ms 512 KB Output is correct
20 Correct 3 ms 512 KB Output is correct
21 Correct 4 ms 512 KB Output is correct
22 Correct 4 ms 512 KB Output is correct
23 Correct 4 ms 512 KB Output is correct
24 Correct 4 ms 512 KB Output is correct
25 Correct 4 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 2 ms 384 KB Output is correct
29 Correct 2 ms 384 KB Output is correct
30 Correct 1 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 4 ms 512 KB Output is correct
40 Correct 4 ms 512 KB Output is correct
41 Correct 3 ms 512 KB Output is correct
42 Correct 4 ms 512 KB Output is correct
43 Correct 3 ms 512 KB Output is correct
44 Correct 4 ms 512 KB Output is correct
45 Correct 3 ms 512 KB Output is correct
46 Correct 4 ms 512 KB Output is correct
47 Correct 3 ms 512 KB Output is correct
48 Correct 1064 ms 47500 KB Output is correct
49 Correct 1080 ms 47504 KB Output is correct
50 Correct 1080 ms 47500 KB Output is correct
51 Correct 1071 ms 47492 KB Output is correct
52 Correct 1057 ms 47500 KB Output is correct
53 Correct 1049 ms 47608 KB Output is correct
54 Correct 1060 ms 47496 KB Output is correct
55 Correct 1073 ms 47492 KB Output is correct
56 Correct 1061 ms 47492 KB Output is correct
57 Correct 1075 ms 47496 KB Output is correct
58 Correct 1065 ms 47500 KB Output is correct
59 Correct 1072 ms 47492 KB Output is correct
60 Correct 1093 ms 47500 KB Output is correct
61 Correct 1109 ms 47508 KB Output is correct
62 Correct 1097 ms 47492 KB Output is correct
63 Correct 1119 ms 47492 KB Output is correct
64 Correct 1079 ms 47480 KB Output is correct
65 Correct 1077 ms 47496 KB Output is correct
66 Correct 1053 ms 47496 KB Output is correct
67 Correct 1050 ms 47496 KB Output is correct
68 Correct 1059 ms 47504 KB Output is correct
69 Correct 1069 ms 47580 KB Output is correct
70 Correct 1054 ms 47496 KB Output is correct
71 Correct 1069 ms 47504 KB Output is correct
72 Correct 1155 ms 47508 KB Output is correct
73 Correct 1056 ms 47492 KB Output is correct
74 Correct 1068 ms 47508 KB Output is correct
75 Correct 1075 ms 47496 KB Output is correct
76 Correct 1078 ms 47504 KB Output is correct
77 Correct 1229 ms 47492 KB Output is correct
78 Correct 1087 ms 47492 KB Output is correct
79 Correct 1078 ms 47496 KB Output is correct
80 Correct 1094 ms 47468 KB Output is correct
81 Correct 1123 ms 47472 KB Output is correct
82 Correct 1067 ms 47468 KB Output is correct
83 Correct 1072 ms 47468 KB Output is correct
84 Correct 1059 ms 47480 KB Output is correct
85 Correct 1079 ms 47472 KB Output is correct
86 Correct 1082 ms 47480 KB Output is correct
87 Correct 1098 ms 47468 KB Output is correct
88 Correct 1107 ms 47476 KB Output is correct
89 Correct 1077 ms 47476 KB Output is correct
90 Correct 1097 ms 47496 KB Output is correct
91 Correct 1058 ms 47496 KB Output is correct
92 Correct 1042 ms 47500 KB Output is correct
93 Correct 1047 ms 47500 KB Output is correct
94 Correct 1045 ms 47492 KB Output is correct
95 Correct 1163 ms 47496 KB Output is correct
96 Correct 1115 ms 47500 KB Output is correct
97 Correct 1097 ms 47500 KB Output is correct
98 Correct 1091 ms 47500 KB Output is correct
99 Correct 1057 ms 47496 KB Output is correct
100 Correct 481 ms 24060 KB Output is correct
101 Correct 507 ms 24112 KB Output is correct
102 Correct 502 ms 23936 KB Output is correct
103 Correct 492 ms 24056 KB Output is correct
104 Correct 503 ms 24048 KB Output is correct
105 Correct 671 ms 31860 KB Output is correct
106 Correct 669 ms 31864 KB Output is correct
107 Correct 689 ms 31856 KB Output is correct
108 Correct 645 ms 31848 KB Output is correct
109 Correct 658 ms 31860 KB Output is correct
110 Correct 1002 ms 46768 KB Output is correct
111 Correct 1041 ms 46768 KB Output is correct
112 Correct 1032 ms 46768 KB Output is correct
113 Correct 1046 ms 46760 KB Output is correct
114 Correct 1020 ms 46712 KB Output is correct
115 Correct 1042 ms 46764 KB Output is correct
116 Correct 1051 ms 46780 KB Output is correct
117 Correct 1022 ms 46764 KB Output is correct
118 Correct 1036 ms 46760 KB Output is correct
119 Correct 1000 ms 46764 KB Output is correct
120 Correct 2 ms 384 KB Output is correct
121 Correct 2 ms 384 KB Output is correct
122 Correct 1086 ms 47488 KB Output is correct
123 Correct 1078 ms 47480 KB Output is correct
124 Correct 1078 ms 47480 KB Output is correct
125 Correct 1076 ms 47488 KB Output is correct
126 Correct 1063 ms 47488 KB Output is correct
127 Correct 1059 ms 47480 KB Output is correct
128 Correct 1047 ms 47604 KB Output is correct
129 Correct 1053 ms 47488 KB Output is correct
130 Correct 1059 ms 47492 KB Output is correct
131 Correct 1092 ms 47492 KB Output is correct
132 Correct 1078 ms 47492 KB Output is correct
133 Correct 1060 ms 47496 KB Output is correct