#include<cstdio>
#include<algorithm>
#define SZ 2048
using namespace std;
struct point2 {
int x, y, i, j;
bool operator<(const point2 &p)const {
return (long long)y*p.x != (long long)p.y*x ? (long long)y*p.x < (long long)p.y*x : i!=p.i?i<p.i:j<p.j;
}
}P[2010000];
struct point {
int x, y, c;
bool operator<(const point &p)const {
return x != p.x ? x < p.x : y < p.y;
}
}w[2010];
long long res;
int n,cnt, Loc[2010];
struct Tree {
long long L[SZ + SZ], R[SZ + SZ], S[SZ + SZ], M[SZ + SZ];
void Put(int a, int b) {
a += SZ;
S[a] = b;
L[a] = R[a] = M[a] = max(0, b);
while (a != 1) {
a >>= 1;
S[a] = S[a + a] + S[a + a + 1];
L[a] = max(L[a + a], S[a + a] + L[a + a + 1]);
R[a] = max(R[a + a + 1], S[a + a + 1] + R[a + a]);
M[a] = max(max(M[a + a], M[a + a + 1]), R[a + a] + L[a + a + 1]);
}
}
}T;
int main() {
int i, j;
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 dx = w[j].x - w[i].x, dy = w[j].y - w[i].y;
if (dx < 0 || (dx == 0 && dy < 0))dx = -dx, dy = -dy;
P[cnt++] = { dx,dy,i,j };
}
}
for (i = 1; i <= n; i++) {
Loc[i] = i;
T.Put(i, w[i].c);
}
sort(P, P + cnt);
res = T.M[1];
for (i = 0; i < cnt; i++) {
for (j = i; j < cnt; j++) {
if ((long long)P[i].x*P[j].y != (long long)P[i].y*P[j].x)break;
int a = P[j].i, b = P[j].j;
swap(Loc[a], Loc[b]);
T.Put(Loc[a], w[a].c);
T.Put(Loc[b], w[b].c);
}
res = max(res, T.M[1]);
i = j - 1;
}
printf("%lld\n", res);
}
Compilation message
bulldozer.cpp: In function 'int main()':
bulldozer.cpp:36:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d", &n);
~~~~~^~~~~~~~~~
bulldozer.cpp:38:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d", &w[i].x, &w[i].y, &w[i].c);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
444 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
484 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 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 |
380 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
412 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
560 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 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 |
2 ms |
408 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
3 ms |
384 KB |
Output is correct |
22 |
Correct |
3 ms |
512 KB |
Output is correct |
23 |
Correct |
3 ms |
384 KB |
Output is correct |
24 |
Correct |
3 ms |
384 KB |
Output is correct |
25 |
Correct |
3 ms |
384 KB |
Output is correct |
26 |
Correct |
3 ms |
384 KB |
Output is correct |
27 |
Correct |
3 ms |
384 KB |
Output is correct |
28 |
Correct |
3 ms |
384 KB |
Output is correct |
29 |
Correct |
3 ms |
384 KB |
Output is correct |
30 |
Correct |
3 ms |
504 KB |
Output is correct |
31 |
Correct |
3 ms |
512 KB |
Output is correct |
32 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
412 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
560 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 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 |
2 ms |
408 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
3 ms |
384 KB |
Output is correct |
22 |
Correct |
3 ms |
512 KB |
Output is correct |
23 |
Correct |
3 ms |
384 KB |
Output is correct |
24 |
Correct |
3 ms |
384 KB |
Output is correct |
25 |
Correct |
3 ms |
384 KB |
Output is correct |
26 |
Correct |
3 ms |
384 KB |
Output is correct |
27 |
Correct |
3 ms |
384 KB |
Output is correct |
28 |
Correct |
3 ms |
384 KB |
Output is correct |
29 |
Correct |
3 ms |
384 KB |
Output is correct |
30 |
Correct |
3 ms |
504 KB |
Output is correct |
31 |
Correct |
3 ms |
512 KB |
Output is correct |
32 |
Correct |
3 ms |
384 KB |
Output is correct |
33 |
Correct |
572 ms |
31836 KB |
Output is correct |
34 |
Correct |
557 ms |
31836 KB |
Output is correct |
35 |
Correct |
598 ms |
31792 KB |
Output is correct |
36 |
Correct |
570 ms |
31804 KB |
Output is correct |
37 |
Correct |
562 ms |
31796 KB |
Output is correct |
38 |
Correct |
552 ms |
31804 KB |
Output is correct |
39 |
Correct |
561 ms |
31800 KB |
Output is correct |
40 |
Correct |
551 ms |
31796 KB |
Output is correct |
41 |
Correct |
556 ms |
31800 KB |
Output is correct |
42 |
Correct |
565 ms |
31864 KB |
Output is correct |
43 |
Correct |
562 ms |
31864 KB |
Output is correct |
44 |
Correct |
585 ms |
31800 KB |
Output is correct |
45 |
Correct |
569 ms |
31808 KB |
Output is correct |
46 |
Correct |
571 ms |
31804 KB |
Output is correct |
47 |
Correct |
611 ms |
31792 KB |
Output is correct |
48 |
Correct |
581 ms |
31796 KB |
Output is correct |
49 |
Correct |
547 ms |
31736 KB |
Output is correct |
50 |
Correct |
545 ms |
31796 KB |
Output is correct |
51 |
Correct |
546 ms |
31796 KB |
Output is correct |
52 |
Correct |
552 ms |
31792 KB |
Output is correct |
53 |
Correct |
578 ms |
31800 KB |
Output is correct |
54 |
Correct |
556 ms |
31800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
412 KB |
Output is correct |
2 |
Correct |
3 ms |
384 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
512 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
560 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 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 |
2 ms |
408 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
3 ms |
384 KB |
Output is correct |
22 |
Correct |
3 ms |
512 KB |
Output is correct |
23 |
Correct |
3 ms |
384 KB |
Output is correct |
24 |
Correct |
3 ms |
384 KB |
Output is correct |
25 |
Correct |
3 ms |
384 KB |
Output is correct |
26 |
Correct |
3 ms |
384 KB |
Output is correct |
27 |
Correct |
3 ms |
384 KB |
Output is correct |
28 |
Correct |
3 ms |
384 KB |
Output is correct |
29 |
Correct |
3 ms |
384 KB |
Output is correct |
30 |
Correct |
3 ms |
504 KB |
Output is correct |
31 |
Correct |
3 ms |
512 KB |
Output is correct |
32 |
Correct |
3 ms |
384 KB |
Output is correct |
33 |
Correct |
572 ms |
31836 KB |
Output is correct |
34 |
Correct |
557 ms |
31836 KB |
Output is correct |
35 |
Correct |
598 ms |
31792 KB |
Output is correct |
36 |
Correct |
570 ms |
31804 KB |
Output is correct |
37 |
Correct |
562 ms |
31796 KB |
Output is correct |
38 |
Correct |
552 ms |
31804 KB |
Output is correct |
39 |
Correct |
561 ms |
31800 KB |
Output is correct |
40 |
Correct |
551 ms |
31796 KB |
Output is correct |
41 |
Correct |
556 ms |
31800 KB |
Output is correct |
42 |
Correct |
565 ms |
31864 KB |
Output is correct |
43 |
Correct |
562 ms |
31864 KB |
Output is correct |
44 |
Correct |
585 ms |
31800 KB |
Output is correct |
45 |
Correct |
569 ms |
31808 KB |
Output is correct |
46 |
Correct |
571 ms |
31804 KB |
Output is correct |
47 |
Correct |
611 ms |
31792 KB |
Output is correct |
48 |
Correct |
581 ms |
31796 KB |
Output is correct |
49 |
Correct |
547 ms |
31736 KB |
Output is correct |
50 |
Correct |
545 ms |
31796 KB |
Output is correct |
51 |
Correct |
546 ms |
31796 KB |
Output is correct |
52 |
Correct |
552 ms |
31792 KB |
Output is correct |
53 |
Correct |
578 ms |
31800 KB |
Output is correct |
54 |
Correct |
556 ms |
31800 KB |
Output is correct |
55 |
Correct |
569 ms |
31808 KB |
Output is correct |
56 |
Correct |
560 ms |
31792 KB |
Output is correct |
57 |
Correct |
573 ms |
31792 KB |
Output is correct |
58 |
Correct |
547 ms |
31864 KB |
Output is correct |
59 |
Correct |
546 ms |
31796 KB |
Output is correct |
60 |
Correct |
557 ms |
31792 KB |
Output is correct |
61 |
Correct |
572 ms |
31736 KB |
Output is correct |
62 |
Correct |
580 ms |
31792 KB |
Output is correct |
63 |
Correct |
565 ms |
31864 KB |
Output is correct |
64 |
Correct |
558 ms |
31796 KB |
Output is correct |
65 |
Correct |
582 ms |
31736 KB |
Output is correct |
66 |
Correct |
590 ms |
31736 KB |
Output is correct |
67 |
Correct |
553 ms |
31864 KB |
Output is correct |
68 |
Correct |
579 ms |
31796 KB |
Output is correct |
69 |
Correct |
549 ms |
31796 KB |
Output is correct |
70 |
Correct |
575 ms |
31796 KB |
Output is correct |
71 |
Correct |
546 ms |
31864 KB |
Output is correct |
72 |
Correct |
558 ms |
31796 KB |
Output is correct |
73 |
Correct |
574 ms |
31864 KB |
Output is correct |
74 |
Correct |
566 ms |
31792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
444 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Correct |
3 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
484 KB |
Output is correct |
5 |
Correct |
3 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
512 KB |
Output is correct |
7 |
Correct |
3 ms |
384 KB |
Output is correct |
8 |
Correct |
3 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 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 |
380 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 |
412 KB |
Output is correct |
17 |
Correct |
3 ms |
384 KB |
Output is correct |
18 |
Correct |
3 ms |
384 KB |
Output is correct |
19 |
Correct |
3 ms |
512 KB |
Output is correct |
20 |
Correct |
3 ms |
384 KB |
Output is correct |
21 |
Correct |
3 ms |
560 KB |
Output is correct |
22 |
Correct |
3 ms |
384 KB |
Output is correct |
23 |
Correct |
3 ms |
384 KB |
Output is correct |
24 |
Correct |
3 ms |
384 KB |
Output is correct |
25 |
Correct |
3 ms |
384 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 |
2 ms |
384 KB |
Output is correct |
31 |
Correct |
2 ms |
408 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |
33 |
Correct |
2 ms |
384 KB |
Output is correct |
34 |
Correct |
1 ms |
384 KB |
Output is correct |
35 |
Correct |
1 ms |
384 KB |
Output is correct |
36 |
Correct |
3 ms |
384 KB |
Output is correct |
37 |
Correct |
3 ms |
512 KB |
Output is correct |
38 |
Correct |
3 ms |
384 KB |
Output is correct |
39 |
Correct |
3 ms |
384 KB |
Output is correct |
40 |
Correct |
3 ms |
384 KB |
Output is correct |
41 |
Correct |
3 ms |
384 KB |
Output is correct |
42 |
Correct |
3 ms |
384 KB |
Output is correct |
43 |
Correct |
3 ms |
384 KB |
Output is correct |
44 |
Correct |
3 ms |
384 KB |
Output is correct |
45 |
Correct |
3 ms |
504 KB |
Output is correct |
46 |
Correct |
3 ms |
512 KB |
Output is correct |
47 |
Correct |
3 ms |
384 KB |
Output is correct |
48 |
Correct |
572 ms |
31836 KB |
Output is correct |
49 |
Correct |
557 ms |
31836 KB |
Output is correct |
50 |
Correct |
598 ms |
31792 KB |
Output is correct |
51 |
Correct |
570 ms |
31804 KB |
Output is correct |
52 |
Correct |
562 ms |
31796 KB |
Output is correct |
53 |
Correct |
552 ms |
31804 KB |
Output is correct |
54 |
Correct |
561 ms |
31800 KB |
Output is correct |
55 |
Correct |
551 ms |
31796 KB |
Output is correct |
56 |
Correct |
556 ms |
31800 KB |
Output is correct |
57 |
Correct |
565 ms |
31864 KB |
Output is correct |
58 |
Correct |
562 ms |
31864 KB |
Output is correct |
59 |
Correct |
585 ms |
31800 KB |
Output is correct |
60 |
Correct |
569 ms |
31808 KB |
Output is correct |
61 |
Correct |
571 ms |
31804 KB |
Output is correct |
62 |
Correct |
611 ms |
31792 KB |
Output is correct |
63 |
Correct |
581 ms |
31796 KB |
Output is correct |
64 |
Correct |
547 ms |
31736 KB |
Output is correct |
65 |
Correct |
545 ms |
31796 KB |
Output is correct |
66 |
Correct |
546 ms |
31796 KB |
Output is correct |
67 |
Correct |
552 ms |
31792 KB |
Output is correct |
68 |
Correct |
578 ms |
31800 KB |
Output is correct |
69 |
Correct |
556 ms |
31800 KB |
Output is correct |
70 |
Correct |
569 ms |
31808 KB |
Output is correct |
71 |
Correct |
560 ms |
31792 KB |
Output is correct |
72 |
Correct |
573 ms |
31792 KB |
Output is correct |
73 |
Correct |
547 ms |
31864 KB |
Output is correct |
74 |
Correct |
546 ms |
31796 KB |
Output is correct |
75 |
Correct |
557 ms |
31792 KB |
Output is correct |
76 |
Correct |
572 ms |
31736 KB |
Output is correct |
77 |
Correct |
580 ms |
31792 KB |
Output is correct |
78 |
Correct |
565 ms |
31864 KB |
Output is correct |
79 |
Correct |
558 ms |
31796 KB |
Output is correct |
80 |
Correct |
582 ms |
31736 KB |
Output is correct |
81 |
Correct |
590 ms |
31736 KB |
Output is correct |
82 |
Correct |
553 ms |
31864 KB |
Output is correct |
83 |
Correct |
579 ms |
31796 KB |
Output is correct |
84 |
Correct |
549 ms |
31796 KB |
Output is correct |
85 |
Correct |
575 ms |
31796 KB |
Output is correct |
86 |
Correct |
546 ms |
31864 KB |
Output is correct |
87 |
Correct |
558 ms |
31796 KB |
Output is correct |
88 |
Correct |
574 ms |
31864 KB |
Output is correct |
89 |
Correct |
566 ms |
31792 KB |
Output is correct |
90 |
Correct |
565 ms |
31864 KB |
Output is correct |
91 |
Correct |
598 ms |
31736 KB |
Output is correct |
92 |
Correct |
565 ms |
31736 KB |
Output is correct |
93 |
Correct |
589 ms |
31800 KB |
Output is correct |
94 |
Correct |
547 ms |
31864 KB |
Output is correct |
95 |
Correct |
545 ms |
31792 KB |
Output is correct |
96 |
Correct |
549 ms |
31864 KB |
Output is correct |
97 |
Correct |
566 ms |
31792 KB |
Output is correct |
98 |
Correct |
560 ms |
31864 KB |
Output is correct |
99 |
Correct |
571 ms |
31744 KB |
Output is correct |
100 |
Correct |
452 ms |
31792 KB |
Output is correct |
101 |
Correct |
451 ms |
31736 KB |
Output is correct |
102 |
Correct |
453 ms |
31836 KB |
Output is correct |
103 |
Correct |
458 ms |
31736 KB |
Output is correct |
104 |
Correct |
520 ms |
31792 KB |
Output is correct |
105 |
Correct |
489 ms |
31792 KB |
Output is correct |
106 |
Correct |
489 ms |
31864 KB |
Output is correct |
107 |
Correct |
478 ms |
31796 KB |
Output is correct |
108 |
Correct |
467 ms |
31796 KB |
Output is correct |
109 |
Correct |
492 ms |
31796 KB |
Output is correct |
110 |
Correct |
548 ms |
31796 KB |
Output is correct |
111 |
Correct |
542 ms |
31792 KB |
Output is correct |
112 |
Correct |
560 ms |
31796 KB |
Output is correct |
113 |
Correct |
535 ms |
31744 KB |
Output is correct |
114 |
Correct |
576 ms |
31864 KB |
Output is correct |
115 |
Correct |
551 ms |
31796 KB |
Output is correct |
116 |
Correct |
554 ms |
31780 KB |
Output is correct |
117 |
Correct |
545 ms |
31792 KB |
Output is correct |
118 |
Correct |
542 ms |
31792 KB |
Output is correct |
119 |
Correct |
547 ms |
31736 KB |
Output is correct |
120 |
Correct |
2 ms |
384 KB |
Output is correct |
121 |
Correct |
2 ms |
384 KB |
Output is correct |
122 |
Correct |
562 ms |
31804 KB |
Output is correct |
123 |
Correct |
548 ms |
31864 KB |
Output is correct |
124 |
Correct |
567 ms |
31800 KB |
Output is correct |
125 |
Correct |
567 ms |
31864 KB |
Output is correct |
126 |
Correct |
611 ms |
31864 KB |
Output is correct |
127 |
Correct |
552 ms |
31864 KB |
Output is correct |
128 |
Correct |
545 ms |
31800 KB |
Output is correct |
129 |
Correct |
554 ms |
31796 KB |
Output is correct |
130 |
Correct |
559 ms |
31792 KB |
Output is correct |
131 |
Correct |
559 ms |
31736 KB |
Output is correct |
132 |
Correct |
571 ms |
31796 KB |
Output is correct |
133 |
Correct |
565 ms |
31868 KB |
Output is correct |