#include <bits/stdc++.h>
using namespace std;
typedef long double F;
typedef complex<F> point;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<point> a(n);
vector<int> w(n);
for (int i = 0; i < n; i++) {
int x, y;
cin >> x >> y >> w[i];
a[i] = point(x, y);
}
vector<F> thetas = [&] { // Gives a list of critical points in [-pi/2,pi/2) in order, expressed by (i, j) : before the critical point i<j and after that i>j. When exactly are the critical points are not returned
vector<F> res = {-1.57079632679};
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
if (y0 != y1) {
F tan = (a[i].real() - a[j].real()) / (a[i].imag() - a[j].imag());
res.push_back(atan(tan));
}
}
}
sort(res.begin(), res.end());
return res;
}();
long long ans = 0;
for (F theta : thetas) {
vector<int> p(n);
iota(p.begin(), p.end(), 0);
sort(p.begin(), p.end(), [&](int i, int j) -> bool {
point x(cos(theta) * a[i].real() - sin(theta) * a[i].imag(), sin(theta) * a[i].real() + cos(theta) * a[i].imag());
point y(cos(theta) * a[j].real() - sin(theta) * a[j].imag(), sin(theta) * a[j].real() + cos(theta) * a[j].imag());
return x.real() < y.real();
});
long long sum = 0;
long long mnsum = 0;
for (int i : p) {
sum += w[i];
ans = max(ans, sum - mnsum);
mnsum = min(mnsum, sum);
}
}
cout << ans << '\n';
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
592 KB |
Output is correct |
2 |
Correct |
53 ms |
592 KB |
Output is correct |
3 |
Correct |
44 ms |
592 KB |
Output is correct |
4 |
Correct |
43 ms |
592 KB |
Output is correct |
5 |
Correct |
50 ms |
592 KB |
Output is correct |
6 |
Correct |
51 ms |
592 KB |
Output is correct |
7 |
Correct |
41 ms |
760 KB |
Output is correct |
8 |
Correct |
47 ms |
848 KB |
Output is correct |
9 |
Correct |
42 ms |
592 KB |
Output is correct |
10 |
Correct |
41 ms |
592 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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
53 ms |
592 KB |
Output is correct |
2 |
Correct |
43 ms |
592 KB |
Output is correct |
3 |
Correct |
53 ms |
592 KB |
Output is correct |
4 |
Correct |
47 ms |
608 KB |
Output is correct |
5 |
Correct |
45 ms |
592 KB |
Output is correct |
6 |
Correct |
51 ms |
592 KB |
Output is correct |
7 |
Correct |
45 ms |
592 KB |
Output is correct |
8 |
Correct |
44 ms |
592 KB |
Output is correct |
9 |
Correct |
53 ms |
592 KB |
Output is correct |
10 |
Correct |
44 ms |
592 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 |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
504 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
44 ms |
592 KB |
Output is correct |
22 |
Correct |
44 ms |
592 KB |
Output is correct |
23 |
Correct |
44 ms |
592 KB |
Output is correct |
24 |
Correct |
43 ms |
592 KB |
Output is correct |
25 |
Correct |
44 ms |
592 KB |
Output is correct |
26 |
Correct |
45 ms |
592 KB |
Output is correct |
27 |
Correct |
48 ms |
760 KB |
Output is correct |
28 |
Correct |
46 ms |
592 KB |
Output is correct |
29 |
Correct |
46 ms |
592 KB |
Output is correct |
30 |
Correct |
51 ms |
592 KB |
Output is correct |
31 |
Correct |
54 ms |
592 KB |
Output is correct |
32 |
Correct |
48 ms |
760 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
53 ms |
592 KB |
Output is correct |
2 |
Correct |
43 ms |
592 KB |
Output is correct |
3 |
Correct |
53 ms |
592 KB |
Output is correct |
4 |
Correct |
47 ms |
608 KB |
Output is correct |
5 |
Correct |
45 ms |
592 KB |
Output is correct |
6 |
Correct |
51 ms |
592 KB |
Output is correct |
7 |
Correct |
45 ms |
592 KB |
Output is correct |
8 |
Correct |
44 ms |
592 KB |
Output is correct |
9 |
Correct |
53 ms |
592 KB |
Output is correct |
10 |
Correct |
44 ms |
592 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 |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
504 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
44 ms |
592 KB |
Output is correct |
22 |
Correct |
44 ms |
592 KB |
Output is correct |
23 |
Correct |
44 ms |
592 KB |
Output is correct |
24 |
Correct |
43 ms |
592 KB |
Output is correct |
25 |
Correct |
44 ms |
592 KB |
Output is correct |
26 |
Correct |
45 ms |
592 KB |
Output is correct |
27 |
Correct |
48 ms |
760 KB |
Output is correct |
28 |
Correct |
46 ms |
592 KB |
Output is correct |
29 |
Correct |
46 ms |
592 KB |
Output is correct |
30 |
Correct |
51 ms |
592 KB |
Output is correct |
31 |
Correct |
54 ms |
592 KB |
Output is correct |
32 |
Correct |
48 ms |
760 KB |
Output is correct |
33 |
Execution timed out |
2051 ms |
35488 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
53 ms |
592 KB |
Output is correct |
2 |
Correct |
43 ms |
592 KB |
Output is correct |
3 |
Correct |
53 ms |
592 KB |
Output is correct |
4 |
Correct |
47 ms |
608 KB |
Output is correct |
5 |
Correct |
45 ms |
592 KB |
Output is correct |
6 |
Correct |
51 ms |
592 KB |
Output is correct |
7 |
Correct |
45 ms |
592 KB |
Output is correct |
8 |
Correct |
44 ms |
592 KB |
Output is correct |
9 |
Correct |
53 ms |
592 KB |
Output is correct |
10 |
Correct |
44 ms |
592 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 |
1 ms |
336 KB |
Output is correct |
17 |
Correct |
1 ms |
336 KB |
Output is correct |
18 |
Correct |
1 ms |
336 KB |
Output is correct |
19 |
Correct |
1 ms |
504 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
44 ms |
592 KB |
Output is correct |
22 |
Correct |
44 ms |
592 KB |
Output is correct |
23 |
Correct |
44 ms |
592 KB |
Output is correct |
24 |
Correct |
43 ms |
592 KB |
Output is correct |
25 |
Correct |
44 ms |
592 KB |
Output is correct |
26 |
Correct |
45 ms |
592 KB |
Output is correct |
27 |
Correct |
48 ms |
760 KB |
Output is correct |
28 |
Correct |
46 ms |
592 KB |
Output is correct |
29 |
Correct |
46 ms |
592 KB |
Output is correct |
30 |
Correct |
51 ms |
592 KB |
Output is correct |
31 |
Correct |
54 ms |
592 KB |
Output is correct |
32 |
Correct |
48 ms |
760 KB |
Output is correct |
33 |
Execution timed out |
2051 ms |
35488 KB |
Time limit exceeded |
34 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
45 ms |
592 KB |
Output is correct |
2 |
Correct |
53 ms |
592 KB |
Output is correct |
3 |
Correct |
44 ms |
592 KB |
Output is correct |
4 |
Correct |
43 ms |
592 KB |
Output is correct |
5 |
Correct |
50 ms |
592 KB |
Output is correct |
6 |
Correct |
51 ms |
592 KB |
Output is correct |
7 |
Correct |
41 ms |
760 KB |
Output is correct |
8 |
Correct |
47 ms |
848 KB |
Output is correct |
9 |
Correct |
42 ms |
592 KB |
Output is correct |
10 |
Correct |
41 ms |
592 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 |
53 ms |
592 KB |
Output is correct |
17 |
Correct |
43 ms |
592 KB |
Output is correct |
18 |
Correct |
53 ms |
592 KB |
Output is correct |
19 |
Correct |
47 ms |
608 KB |
Output is correct |
20 |
Correct |
45 ms |
592 KB |
Output is correct |
21 |
Correct |
51 ms |
592 KB |
Output is correct |
22 |
Correct |
45 ms |
592 KB |
Output is correct |
23 |
Correct |
44 ms |
592 KB |
Output is correct |
24 |
Correct |
53 ms |
592 KB |
Output is correct |
25 |
Correct |
44 ms |
592 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Correct |
1 ms |
336 KB |
Output is correct |
30 |
Correct |
1 ms |
336 KB |
Output is correct |
31 |
Correct |
1 ms |
336 KB |
Output is correct |
32 |
Correct |
1 ms |
336 KB |
Output is correct |
33 |
Correct |
1 ms |
336 KB |
Output is correct |
34 |
Correct |
1 ms |
504 KB |
Output is correct |
35 |
Correct |
1 ms |
336 KB |
Output is correct |
36 |
Correct |
44 ms |
592 KB |
Output is correct |
37 |
Correct |
44 ms |
592 KB |
Output is correct |
38 |
Correct |
44 ms |
592 KB |
Output is correct |
39 |
Correct |
43 ms |
592 KB |
Output is correct |
40 |
Correct |
44 ms |
592 KB |
Output is correct |
41 |
Correct |
45 ms |
592 KB |
Output is correct |
42 |
Correct |
48 ms |
760 KB |
Output is correct |
43 |
Correct |
46 ms |
592 KB |
Output is correct |
44 |
Correct |
46 ms |
592 KB |
Output is correct |
45 |
Correct |
51 ms |
592 KB |
Output is correct |
46 |
Correct |
54 ms |
592 KB |
Output is correct |
47 |
Correct |
48 ms |
760 KB |
Output is correct |
48 |
Execution timed out |
2051 ms |
35488 KB |
Time limit exceeded |
49 |
Halted |
0 ms |
0 KB |
- |