#include <bits/stdc++.h>
using namespace std;
typedef complex<long long> point;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<pair<point, int>> a;
for (int i = 0; i < n; i++) {
int x, y, w;
cin >> x >> y >> w;
a.emplace_back(point(x, y), w);
}
if (n == 1) {
cout << max(0, a[0].second) << '\n';
return 0;
}
// sort(a.begin(), a.end(), [&](auto x, auto y) {
// if (x.first.real() != y.first.real()) return x.first.real() < y.first.real();
// return x.first.imag() < y.first.imag();
// });
long long ans = 0;
for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (i != j) {
point line = a[i].first - a[j].first;
vector<pair<point, int>> b = a;
sort(b.begin(), b.end(), [&](auto xw, auto yw) {
point x = xw. first, y = yw.first;
point X(line.real() * x.real() + line.imag() * x.imag(), -line.imag() * x.real() + line.real() * x.imag());
point Y(line.real() * y.real() + line.imag() * y.imag(), -line.imag() * y.real() + line.real() * y.imag());
if (X.real() != Y.real()) return X.real() < Y.real();
return X.imag() < Y.imag();
});
long long sum = 0;
long long mnsum = 0;
for (auto [p, w] : b) {
sum += w;
ans = max(ans, sum - mnsum);
mnsum = min(mnsum, sum);
}
}
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
336 KB |
Output is correct |
2 |
Correct |
16 ms |
464 KB |
Output is correct |
3 |
Correct |
16 ms |
516 KB |
Output is correct |
4 |
Correct |
17 ms |
468 KB |
Output is correct |
5 |
Correct |
17 ms |
336 KB |
Output is correct |
6 |
Correct |
15 ms |
468 KB |
Output is correct |
7 |
Correct |
18 ms |
504 KB |
Output is correct |
8 |
Correct |
15 ms |
336 KB |
Output is correct |
9 |
Correct |
15 ms |
336 KB |
Output is correct |
10 |
Correct |
17 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
336 KB |
Output is correct |
2 |
Correct |
35 ms |
336 KB |
Output is correct |
3 |
Correct |
34 ms |
336 KB |
Output is correct |
4 |
Correct |
36 ms |
336 KB |
Output is correct |
5 |
Correct |
36 ms |
336 KB |
Output is correct |
6 |
Correct |
35 ms |
336 KB |
Output is correct |
7 |
Correct |
36 ms |
336 KB |
Output is correct |
8 |
Incorrect |
35 ms |
336 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
336 KB |
Output is correct |
2 |
Correct |
35 ms |
336 KB |
Output is correct |
3 |
Correct |
34 ms |
336 KB |
Output is correct |
4 |
Correct |
36 ms |
336 KB |
Output is correct |
5 |
Correct |
36 ms |
336 KB |
Output is correct |
6 |
Correct |
35 ms |
336 KB |
Output is correct |
7 |
Correct |
36 ms |
336 KB |
Output is correct |
8 |
Incorrect |
35 ms |
336 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
336 KB |
Output is correct |
2 |
Correct |
35 ms |
336 KB |
Output is correct |
3 |
Correct |
34 ms |
336 KB |
Output is correct |
4 |
Correct |
36 ms |
336 KB |
Output is correct |
5 |
Correct |
36 ms |
336 KB |
Output is correct |
6 |
Correct |
35 ms |
336 KB |
Output is correct |
7 |
Correct |
36 ms |
336 KB |
Output is correct |
8 |
Incorrect |
35 ms |
336 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
336 KB |
Output is correct |
2 |
Correct |
16 ms |
464 KB |
Output is correct |
3 |
Correct |
16 ms |
516 KB |
Output is correct |
4 |
Correct |
17 ms |
468 KB |
Output is correct |
5 |
Correct |
17 ms |
336 KB |
Output is correct |
6 |
Correct |
15 ms |
468 KB |
Output is correct |
7 |
Correct |
18 ms |
504 KB |
Output is correct |
8 |
Correct |
15 ms |
336 KB |
Output is correct |
9 |
Correct |
15 ms |
336 KB |
Output is correct |
10 |
Correct |
17 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
37 ms |
336 KB |
Output is correct |
17 |
Correct |
35 ms |
336 KB |
Output is correct |
18 |
Correct |
34 ms |
336 KB |
Output is correct |
19 |
Correct |
36 ms |
336 KB |
Output is correct |
20 |
Correct |
36 ms |
336 KB |
Output is correct |
21 |
Correct |
35 ms |
336 KB |
Output is correct |
22 |
Correct |
36 ms |
336 KB |
Output is correct |
23 |
Incorrect |
35 ms |
336 KB |
Output isn't correct |
24 |
Halted |
0 ms |
0 KB |
- |