#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct pct
{
int x,y,c;
bool operator< (const pct &aux) const
{
if (x!=aux.x)
return x<aux.x;
return y<aux.y;
}
}w[2005];
struct pct2
{
int x,y,i,j;
bool operator< (const pct2 &aux) const
{
if (1LL*y*aux.x!=1LL*aux.y*x)
return 1LL*y*aux.x<1LL*aux.y*x;
if (i!=aux.i)
return i<aux.i;
return j<aux.j;
}
}v[2000005];
int l[2005];
struct ain
{
ll l[5000],r[5000],sum[5000],maxi[5000];
void update(int poz,int val)
{
poz+=2048;
sum[poz]=val;
l[poz]=r[poz]=maxi[poz]=max(0,val);
while(poz!=1){
poz=poz/2;
sum[poz]=sum[poz*2]+sum[poz*2+1];
l[poz]=max(l[poz*2],sum[poz*2]+l[poz*2+1]);
r[poz]=max(r[poz*2+1],sum[poz*2+1]+r[poz*2]);
maxi[poz]=max(max(maxi[poz*2],maxi[poz*2+1]),r[poz*2]+l[poz*2+1]);
}
}
}aint;
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
int n,i,j,u=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
scanf("%d%d%d",&w[i].x,&w[i].y,&w[i].c);
sort(w+1,w+n+1);
for(i=1;i<n;i++)
for(j=i+1;j<=n;j++){
int x=w[j].x-w[i].x,y=w[j].y-w[i].y;
if (x<0 || (x==0 && y<0))
x=-x,y=-y;
v[u++]={x,y,i,j};
}
for(i=1;i<=n;i++){
l[i]=i;
aint.update(i,w[i].c);
}
sort(v,v+u);
ll ans=aint.maxi[1];
for(i=0;i<u;i++){
for(j=i;j<u;j++){
if (1LL*v[i].x*v[j].y!=1LL*v[i].y*v[j].x)
break;
int x=v[j].i,y=v[j].j;
swap(l[x],l[y]);
aint.update(l[x],w[x].c);
aint.update(l[y],w[y].c);
}
ans=max(ans,aint.maxi[1]);
i=j-1;
}
printf("%lld\n",ans);
return 0;
}
Compilation message
bulldozer.cpp: In function 'int main()':
bulldozer.cpp:49:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
49 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
bulldozer.cpp:51:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
51 | scanf("%d%d%d",&w[i].x,&w[i].y,&w[i].c);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
492 KB |
Output is correct |
2 |
Correct |
2 ms |
492 KB |
Output is correct |
3 |
Correct |
2 ms |
492 KB |
Output is correct |
4 |
Correct |
2 ms |
492 KB |
Output is correct |
5 |
Correct |
1 ms |
492 KB |
Output is correct |
6 |
Correct |
2 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
492 KB |
Output is correct |
8 |
Correct |
1 ms |
492 KB |
Output is correct |
9 |
Correct |
1 ms |
492 KB |
Output is correct |
10 |
Correct |
2 ms |
492 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
2 ms |
492 KB |
Output is correct |
3 |
Correct |
2 ms |
492 KB |
Output is correct |
4 |
Correct |
2 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
2 ms |
492 KB |
Output is correct |
7 |
Correct |
2 ms |
492 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
3 ms |
524 KB |
Output is correct |
10 |
Correct |
2 ms |
492 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
508 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
2 ms |
492 KB |
Output is correct |
22 |
Correct |
2 ms |
492 KB |
Output is correct |
23 |
Correct |
2 ms |
492 KB |
Output is correct |
24 |
Correct |
2 ms |
492 KB |
Output is correct |
25 |
Correct |
2 ms |
620 KB |
Output is correct |
26 |
Correct |
2 ms |
492 KB |
Output is correct |
27 |
Correct |
2 ms |
492 KB |
Output is correct |
28 |
Correct |
2 ms |
492 KB |
Output is correct |
29 |
Correct |
2 ms |
492 KB |
Output is correct |
30 |
Correct |
2 ms |
492 KB |
Output is correct |
31 |
Correct |
2 ms |
640 KB |
Output is correct |
32 |
Correct |
2 ms |
492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
2 ms |
492 KB |
Output is correct |
3 |
Correct |
2 ms |
492 KB |
Output is correct |
4 |
Correct |
2 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
2 ms |
492 KB |
Output is correct |
7 |
Correct |
2 ms |
492 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
3 ms |
524 KB |
Output is correct |
10 |
Correct |
2 ms |
492 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
508 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
2 ms |
492 KB |
Output is correct |
22 |
Correct |
2 ms |
492 KB |
Output is correct |
23 |
Correct |
2 ms |
492 KB |
Output is correct |
24 |
Correct |
2 ms |
492 KB |
Output is correct |
25 |
Correct |
2 ms |
620 KB |
Output is correct |
26 |
Correct |
2 ms |
492 KB |
Output is correct |
27 |
Correct |
2 ms |
492 KB |
Output is correct |
28 |
Correct |
2 ms |
492 KB |
Output is correct |
29 |
Correct |
2 ms |
492 KB |
Output is correct |
30 |
Correct |
2 ms |
492 KB |
Output is correct |
31 |
Correct |
2 ms |
640 KB |
Output is correct |
32 |
Correct |
2 ms |
492 KB |
Output is correct |
33 |
Correct |
575 ms |
31852 KB |
Output is correct |
34 |
Correct |
574 ms |
31916 KB |
Output is correct |
35 |
Correct |
569 ms |
31980 KB |
Output is correct |
36 |
Correct |
578 ms |
31852 KB |
Output is correct |
37 |
Correct |
577 ms |
31980 KB |
Output is correct |
38 |
Correct |
569 ms |
31980 KB |
Output is correct |
39 |
Correct |
600 ms |
31980 KB |
Output is correct |
40 |
Correct |
565 ms |
31852 KB |
Output is correct |
41 |
Correct |
589 ms |
31852 KB |
Output is correct |
42 |
Correct |
573 ms |
31852 KB |
Output is correct |
43 |
Correct |
590 ms |
31980 KB |
Output is correct |
44 |
Correct |
562 ms |
31916 KB |
Output is correct |
45 |
Correct |
569 ms |
31916 KB |
Output is correct |
46 |
Correct |
562 ms |
31980 KB |
Output is correct |
47 |
Correct |
557 ms |
31852 KB |
Output is correct |
48 |
Correct |
559 ms |
31916 KB |
Output is correct |
49 |
Correct |
562 ms |
31980 KB |
Output is correct |
50 |
Correct |
562 ms |
31980 KB |
Output is correct |
51 |
Correct |
560 ms |
31980 KB |
Output is correct |
52 |
Correct |
571 ms |
31916 KB |
Output is correct |
53 |
Correct |
567 ms |
31980 KB |
Output is correct |
54 |
Correct |
557 ms |
31980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
2 ms |
492 KB |
Output is correct |
3 |
Correct |
2 ms |
492 KB |
Output is correct |
4 |
Correct |
2 ms |
492 KB |
Output is correct |
5 |
Correct |
2 ms |
492 KB |
Output is correct |
6 |
Correct |
2 ms |
492 KB |
Output is correct |
7 |
Correct |
2 ms |
492 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
3 ms |
524 KB |
Output is correct |
10 |
Correct |
2 ms |
492 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
508 KB |
Output is correct |
16 |
Correct |
1 ms |
364 KB |
Output is correct |
17 |
Correct |
1 ms |
364 KB |
Output is correct |
18 |
Correct |
1 ms |
364 KB |
Output is correct |
19 |
Correct |
1 ms |
364 KB |
Output is correct |
20 |
Correct |
1 ms |
364 KB |
Output is correct |
21 |
Correct |
2 ms |
492 KB |
Output is correct |
22 |
Correct |
2 ms |
492 KB |
Output is correct |
23 |
Correct |
2 ms |
492 KB |
Output is correct |
24 |
Correct |
2 ms |
492 KB |
Output is correct |
25 |
Correct |
2 ms |
620 KB |
Output is correct |
26 |
Correct |
2 ms |
492 KB |
Output is correct |
27 |
Correct |
2 ms |
492 KB |
Output is correct |
28 |
Correct |
2 ms |
492 KB |
Output is correct |
29 |
Correct |
2 ms |
492 KB |
Output is correct |
30 |
Correct |
2 ms |
492 KB |
Output is correct |
31 |
Correct |
2 ms |
640 KB |
Output is correct |
32 |
Correct |
2 ms |
492 KB |
Output is correct |
33 |
Correct |
575 ms |
31852 KB |
Output is correct |
34 |
Correct |
574 ms |
31916 KB |
Output is correct |
35 |
Correct |
569 ms |
31980 KB |
Output is correct |
36 |
Correct |
578 ms |
31852 KB |
Output is correct |
37 |
Correct |
577 ms |
31980 KB |
Output is correct |
38 |
Correct |
569 ms |
31980 KB |
Output is correct |
39 |
Correct |
600 ms |
31980 KB |
Output is correct |
40 |
Correct |
565 ms |
31852 KB |
Output is correct |
41 |
Correct |
589 ms |
31852 KB |
Output is correct |
42 |
Correct |
573 ms |
31852 KB |
Output is correct |
43 |
Correct |
590 ms |
31980 KB |
Output is correct |
44 |
Correct |
562 ms |
31916 KB |
Output is correct |
45 |
Correct |
569 ms |
31916 KB |
Output is correct |
46 |
Correct |
562 ms |
31980 KB |
Output is correct |
47 |
Correct |
557 ms |
31852 KB |
Output is correct |
48 |
Correct |
559 ms |
31916 KB |
Output is correct |
49 |
Correct |
562 ms |
31980 KB |
Output is correct |
50 |
Correct |
562 ms |
31980 KB |
Output is correct |
51 |
Correct |
560 ms |
31980 KB |
Output is correct |
52 |
Correct |
571 ms |
31916 KB |
Output is correct |
53 |
Correct |
567 ms |
31980 KB |
Output is correct |
54 |
Correct |
557 ms |
31980 KB |
Output is correct |
55 |
Correct |
562 ms |
31852 KB |
Output is correct |
56 |
Correct |
563 ms |
31852 KB |
Output is correct |
57 |
Correct |
567 ms |
32012 KB |
Output is correct |
58 |
Correct |
580 ms |
31916 KB |
Output is correct |
59 |
Correct |
570 ms |
31916 KB |
Output is correct |
60 |
Correct |
574 ms |
31980 KB |
Output is correct |
61 |
Correct |
575 ms |
31980 KB |
Output is correct |
62 |
Correct |
575 ms |
31980 KB |
Output is correct |
63 |
Correct |
567 ms |
31980 KB |
Output is correct |
64 |
Correct |
574 ms |
31980 KB |
Output is correct |
65 |
Correct |
558 ms |
31852 KB |
Output is correct |
66 |
Correct |
566 ms |
31852 KB |
Output is correct |
67 |
Correct |
563 ms |
31980 KB |
Output is correct |
68 |
Correct |
566 ms |
31852 KB |
Output is correct |
69 |
Correct |
560 ms |
31916 KB |
Output is correct |
70 |
Correct |
573 ms |
31980 KB |
Output is correct |
71 |
Correct |
570 ms |
31916 KB |
Output is correct |
72 |
Correct |
575 ms |
31916 KB |
Output is correct |
73 |
Correct |
581 ms |
31980 KB |
Output is correct |
74 |
Correct |
571 ms |
31980 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
492 KB |
Output is correct |
2 |
Correct |
2 ms |
492 KB |
Output is correct |
3 |
Correct |
2 ms |
492 KB |
Output is correct |
4 |
Correct |
2 ms |
492 KB |
Output is correct |
5 |
Correct |
1 ms |
492 KB |
Output is correct |
6 |
Correct |
2 ms |
492 KB |
Output is correct |
7 |
Correct |
1 ms |
492 KB |
Output is correct |
8 |
Correct |
1 ms |
492 KB |
Output is correct |
9 |
Correct |
1 ms |
492 KB |
Output is correct |
10 |
Correct |
2 ms |
492 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
2 ms |
512 KB |
Output is correct |
17 |
Correct |
2 ms |
492 KB |
Output is correct |
18 |
Correct |
2 ms |
492 KB |
Output is correct |
19 |
Correct |
2 ms |
492 KB |
Output is correct |
20 |
Correct |
2 ms |
492 KB |
Output is correct |
21 |
Correct |
2 ms |
492 KB |
Output is correct |
22 |
Correct |
2 ms |
492 KB |
Output is correct |
23 |
Correct |
2 ms |
492 KB |
Output is correct |
24 |
Correct |
3 ms |
524 KB |
Output is correct |
25 |
Correct |
2 ms |
492 KB |
Output is correct |
26 |
Correct |
1 ms |
364 KB |
Output is correct |
27 |
Correct |
1 ms |
364 KB |
Output is correct |
28 |
Correct |
1 ms |
364 KB |
Output is correct |
29 |
Correct |
1 ms |
364 KB |
Output is correct |
30 |
Correct |
1 ms |
508 KB |
Output is correct |
31 |
Correct |
1 ms |
364 KB |
Output is correct |
32 |
Correct |
1 ms |
364 KB |
Output is correct |
33 |
Correct |
1 ms |
364 KB |
Output is correct |
34 |
Correct |
1 ms |
364 KB |
Output is correct |
35 |
Correct |
1 ms |
364 KB |
Output is correct |
36 |
Correct |
2 ms |
492 KB |
Output is correct |
37 |
Correct |
2 ms |
492 KB |
Output is correct |
38 |
Correct |
2 ms |
492 KB |
Output is correct |
39 |
Correct |
2 ms |
492 KB |
Output is correct |
40 |
Correct |
2 ms |
620 KB |
Output is correct |
41 |
Correct |
2 ms |
492 KB |
Output is correct |
42 |
Correct |
2 ms |
492 KB |
Output is correct |
43 |
Correct |
2 ms |
492 KB |
Output is correct |
44 |
Correct |
2 ms |
492 KB |
Output is correct |
45 |
Correct |
2 ms |
492 KB |
Output is correct |
46 |
Correct |
2 ms |
640 KB |
Output is correct |
47 |
Correct |
2 ms |
492 KB |
Output is correct |
48 |
Correct |
575 ms |
31852 KB |
Output is correct |
49 |
Correct |
574 ms |
31916 KB |
Output is correct |
50 |
Correct |
569 ms |
31980 KB |
Output is correct |
51 |
Correct |
578 ms |
31852 KB |
Output is correct |
52 |
Correct |
577 ms |
31980 KB |
Output is correct |
53 |
Correct |
569 ms |
31980 KB |
Output is correct |
54 |
Correct |
600 ms |
31980 KB |
Output is correct |
55 |
Correct |
565 ms |
31852 KB |
Output is correct |
56 |
Correct |
589 ms |
31852 KB |
Output is correct |
57 |
Correct |
573 ms |
31852 KB |
Output is correct |
58 |
Correct |
590 ms |
31980 KB |
Output is correct |
59 |
Correct |
562 ms |
31916 KB |
Output is correct |
60 |
Correct |
569 ms |
31916 KB |
Output is correct |
61 |
Correct |
562 ms |
31980 KB |
Output is correct |
62 |
Correct |
557 ms |
31852 KB |
Output is correct |
63 |
Correct |
559 ms |
31916 KB |
Output is correct |
64 |
Correct |
562 ms |
31980 KB |
Output is correct |
65 |
Correct |
562 ms |
31980 KB |
Output is correct |
66 |
Correct |
560 ms |
31980 KB |
Output is correct |
67 |
Correct |
571 ms |
31916 KB |
Output is correct |
68 |
Correct |
567 ms |
31980 KB |
Output is correct |
69 |
Correct |
557 ms |
31980 KB |
Output is correct |
70 |
Correct |
562 ms |
31852 KB |
Output is correct |
71 |
Correct |
563 ms |
31852 KB |
Output is correct |
72 |
Correct |
567 ms |
32012 KB |
Output is correct |
73 |
Correct |
580 ms |
31916 KB |
Output is correct |
74 |
Correct |
570 ms |
31916 KB |
Output is correct |
75 |
Correct |
574 ms |
31980 KB |
Output is correct |
76 |
Correct |
575 ms |
31980 KB |
Output is correct |
77 |
Correct |
575 ms |
31980 KB |
Output is correct |
78 |
Correct |
567 ms |
31980 KB |
Output is correct |
79 |
Correct |
574 ms |
31980 KB |
Output is correct |
80 |
Correct |
558 ms |
31852 KB |
Output is correct |
81 |
Correct |
566 ms |
31852 KB |
Output is correct |
82 |
Correct |
563 ms |
31980 KB |
Output is correct |
83 |
Correct |
566 ms |
31852 KB |
Output is correct |
84 |
Correct |
560 ms |
31916 KB |
Output is correct |
85 |
Correct |
573 ms |
31980 KB |
Output is correct |
86 |
Correct |
570 ms |
31916 KB |
Output is correct |
87 |
Correct |
575 ms |
31916 KB |
Output is correct |
88 |
Correct |
581 ms |
31980 KB |
Output is correct |
89 |
Correct |
571 ms |
31980 KB |
Output is correct |
90 |
Correct |
566 ms |
31852 KB |
Output is correct |
91 |
Correct |
587 ms |
31980 KB |
Output is correct |
92 |
Correct |
574 ms |
31980 KB |
Output is correct |
93 |
Correct |
565 ms |
31852 KB |
Output is correct |
94 |
Correct |
568 ms |
31852 KB |
Output is correct |
95 |
Correct |
613 ms |
31916 KB |
Output is correct |
96 |
Correct |
575 ms |
31852 KB |
Output is correct |
97 |
Correct |
577 ms |
31852 KB |
Output is correct |
98 |
Correct |
574 ms |
31944 KB |
Output is correct |
99 |
Correct |
619 ms |
31916 KB |
Output is correct |
100 |
Correct |
456 ms |
31900 KB |
Output is correct |
101 |
Correct |
454 ms |
31980 KB |
Output is correct |
102 |
Correct |
450 ms |
31852 KB |
Output is correct |
103 |
Correct |
550 ms |
31900 KB |
Output is correct |
104 |
Correct |
450 ms |
31900 KB |
Output is correct |
105 |
Correct |
477 ms |
31852 KB |
Output is correct |
106 |
Correct |
482 ms |
31980 KB |
Output is correct |
107 |
Correct |
488 ms |
31980 KB |
Output is correct |
108 |
Correct |
472 ms |
31904 KB |
Output is correct |
109 |
Correct |
499 ms |
31900 KB |
Output is correct |
110 |
Correct |
584 ms |
31892 KB |
Output is correct |
111 |
Correct |
561 ms |
31792 KB |
Output is correct |
112 |
Correct |
556 ms |
31892 KB |
Output is correct |
113 |
Correct |
570 ms |
31852 KB |
Output is correct |
114 |
Correct |
549 ms |
31892 KB |
Output is correct |
115 |
Correct |
555 ms |
31980 KB |
Output is correct |
116 |
Correct |
565 ms |
31892 KB |
Output is correct |
117 |
Correct |
581 ms |
31852 KB |
Output is correct |
118 |
Correct |
547 ms |
31892 KB |
Output is correct |
119 |
Correct |
549 ms |
31892 KB |
Output is correct |
120 |
Correct |
1 ms |
364 KB |
Output is correct |
121 |
Correct |
1 ms |
364 KB |
Output is correct |
122 |
Correct |
581 ms |
31916 KB |
Output is correct |
123 |
Correct |
589 ms |
31852 KB |
Output is correct |
124 |
Correct |
570 ms |
31916 KB |
Output is correct |
125 |
Correct |
568 ms |
31980 KB |
Output is correct |
126 |
Correct |
568 ms |
31960 KB |
Output is correct |
127 |
Correct |
573 ms |
31980 KB |
Output is correct |
128 |
Correct |
569 ms |
31852 KB |
Output is correct |
129 |
Correct |
563 ms |
31980 KB |
Output is correct |
130 |
Correct |
564 ms |
32012 KB |
Output is correct |
131 |
Correct |
564 ms |
31852 KB |
Output is correct |
132 |
Correct |
574 ms |
31980 KB |
Output is correct |
133 |
Correct |
569 ms |
31916 KB |
Output is correct |