// V T An
#include <bits/stdc++.h>
#define Task "BULLDOZER"
#define F first
#define S second
using namespace std;
const int maxn = 2005;
int n;
struct data {
long long x, y, w;
bool operator < (const data A) {
return x < A.x;
}
} point[maxn];
namespace Sub1 {
long long s[maxn], ans = 0;
void Solve() {
sort(point + 1, point + n + 1);
for(int i = 1; i <= n; ++ i) {
s[i] = s[i - 1] + point[i].w;
}
for(int i = 1; i <= n; ++ i) {
for(int j = i; j <= n; ++ j) {
ans = max(ans, s[j] - s[i - 1]);
}
}
cout << ans << "\n";
}
}
namespace Sub2 {
long long A, B, C;
int cnt = 0;
long long cur[maxn];
data Save[maxn];
long long DistoLine(long long a, long long b, long long c, long long x, long long y) {
return a * x + b * y + c;
}
bool comp(data p, data q) {
return DistoLine(A, B, C, p.x, p.y) < DistoLine(A, B, C, q.x, q.y);
}
void Solve() {
long long ans = 0;
for(int i = 1; i <= n; ++ i) Save[i] = point[i];
for(int i = 1; i <= n; ++ i) {
pair<long long, long long> c = {point[i].x, point[i].y};
ans = max(ans, point[i].w);
for(int j = 1; j <= n; ++ j) {
pair<long long, long long> d = {point[j].x, point[j].y};
pair<long long, long long> u = {d.F - c.F, d.S - c.S};
A = u.S, B = -u.F, C = - (A * c.F + B * c.S);
cnt = 0;
sort(point + 1, point + n + 1, comp);
for(int k = 1; k <= n; ++ k) {
if(k > 1 && DistoLine(A, B, C, point[k].x, point[k].y) == DistoLine(A, B, C, point[k - 1].x, point[k - 1].y)){
cur[cnt] += point[k].w;
} else cur[++ cnt] = point[k].w;
}
for(int k = 1; k <= cnt; ++ k) cur[k] += cur[k - 1];
for(int p = 1; p <= cnt; ++ p)
for(int q = p; q <= cnt; ++ q)
ans = max(ans, cur[q] - cur[p - 1]);
for(int k = 1; k <= n; ++ k) point[k] = Save[k];
}
}
cout << ans;
}
}
int main() {
ios_base::sync_with_stdio(0);
cout.tie(0); cin.tie(0);
if(fopen(Task".inp", "r")){
freopen(Task".inp", "r", stdin);
freopen(Task".out", "w", stdout);
}
cin >> n;
int sub1 = 1;
for(int i = 1; i <= n; ++ i) {
int x, y, w;
cin >> x >> y >> w;
point[i] = {x, y, w};
if(y) sub1 = 0;
}
if(sub1) {
Sub1::Solve();
return 0;
}
Sub2::Solve();
}
// CHY-AKAV
Compilation message
bulldozer.cpp: In function 'int main()':
bulldozer.cpp:85:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
85 | freopen(Task".inp", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bulldozer.cpp:86:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
86 | freopen(Task".out", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
500 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
0 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
0 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
138 ms |
428 KB |
Output is correct |
2 |
Correct |
155 ms |
492 KB |
Output is correct |
3 |
Correct |
150 ms |
416 KB |
Output is correct |
4 |
Correct |
141 ms |
492 KB |
Output is correct |
5 |
Correct |
140 ms |
492 KB |
Output is correct |
6 |
Correct |
150 ms |
384 KB |
Output is correct |
7 |
Correct |
163 ms |
364 KB |
Output is correct |
8 |
Correct |
143 ms |
364 KB |
Output is correct |
9 |
Correct |
144 ms |
492 KB |
Output is correct |
10 |
Correct |
148 ms |
364 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 |
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 |
138 ms |
364 KB |
Output is correct |
22 |
Correct |
138 ms |
492 KB |
Output is correct |
23 |
Correct |
139 ms |
516 KB |
Output is correct |
24 |
Correct |
136 ms |
492 KB |
Output is correct |
25 |
Incorrect |
137 ms |
492 KB |
Output isn't correct |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
138 ms |
428 KB |
Output is correct |
2 |
Correct |
155 ms |
492 KB |
Output is correct |
3 |
Correct |
150 ms |
416 KB |
Output is correct |
4 |
Correct |
141 ms |
492 KB |
Output is correct |
5 |
Correct |
140 ms |
492 KB |
Output is correct |
6 |
Correct |
150 ms |
384 KB |
Output is correct |
7 |
Correct |
163 ms |
364 KB |
Output is correct |
8 |
Correct |
143 ms |
364 KB |
Output is correct |
9 |
Correct |
144 ms |
492 KB |
Output is correct |
10 |
Correct |
148 ms |
364 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 |
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 |
138 ms |
364 KB |
Output is correct |
22 |
Correct |
138 ms |
492 KB |
Output is correct |
23 |
Correct |
139 ms |
516 KB |
Output is correct |
24 |
Correct |
136 ms |
492 KB |
Output is correct |
25 |
Incorrect |
137 ms |
492 KB |
Output isn't correct |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
138 ms |
428 KB |
Output is correct |
2 |
Correct |
155 ms |
492 KB |
Output is correct |
3 |
Correct |
150 ms |
416 KB |
Output is correct |
4 |
Correct |
141 ms |
492 KB |
Output is correct |
5 |
Correct |
140 ms |
492 KB |
Output is correct |
6 |
Correct |
150 ms |
384 KB |
Output is correct |
7 |
Correct |
163 ms |
364 KB |
Output is correct |
8 |
Correct |
143 ms |
364 KB |
Output is correct |
9 |
Correct |
144 ms |
492 KB |
Output is correct |
10 |
Correct |
148 ms |
364 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 |
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 |
138 ms |
364 KB |
Output is correct |
22 |
Correct |
138 ms |
492 KB |
Output is correct |
23 |
Correct |
139 ms |
516 KB |
Output is correct |
24 |
Correct |
136 ms |
492 KB |
Output is correct |
25 |
Incorrect |
137 ms |
492 KB |
Output isn't correct |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
500 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
0 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
0 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 |
138 ms |
428 KB |
Output is correct |
17 |
Correct |
155 ms |
492 KB |
Output is correct |
18 |
Correct |
150 ms |
416 KB |
Output is correct |
19 |
Correct |
141 ms |
492 KB |
Output is correct |
20 |
Correct |
140 ms |
492 KB |
Output is correct |
21 |
Correct |
150 ms |
384 KB |
Output is correct |
22 |
Correct |
163 ms |
364 KB |
Output is correct |
23 |
Correct |
143 ms |
364 KB |
Output is correct |
24 |
Correct |
144 ms |
492 KB |
Output is correct |
25 |
Correct |
148 ms |
364 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 |
364 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 |
138 ms |
364 KB |
Output is correct |
37 |
Correct |
138 ms |
492 KB |
Output is correct |
38 |
Correct |
139 ms |
516 KB |
Output is correct |
39 |
Correct |
136 ms |
492 KB |
Output is correct |
40 |
Incorrect |
137 ms |
492 KB |
Output isn't correct |
41 |
Halted |
0 ms |
0 KB |
- |