#include <tuple>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
struct point {
long long x, y;
point() : x(0), y(0) {};
point(long long x_, long long y_) : x(x_), y(y_) {};
point operator+(const point& p) const { return point(x + p.x, y + p.y); }
point operator-(const point& p) const { return point(x - p.x, y - p.y); }
long long cross(const point& p) const { return x * p.y - y - p.x; }
};
int shougen(const point &p) {
if(p.y == 0) return p.x > 0 ? 0 : 2;
return p.y > 0 ? 1 : 3;
}
int main() {
int N;
cin >> N;
vector<point> P(N);
vector<long long> V(N);
for(int i = 0; i < N; ++i) {
cin >> P[i].x >> P[i].y >> V[i];
}
vector<int> perm(N);
for(int i = 0; i < N; ++i) perm[i] = i;
sort(perm.begin(), perm.end(), [&](int i, int j) { return P[i].y != P[j].y ? P[i].y < P[j].y : P[i].x < P[j].x; });
vector<int> inv(N);
for(int i = 0; i < N; ++i) inv[perm[i]] = i;
vector<tuple<point, int, int> > vec;
for(int i = 0; i < N; ++i) {
for(int j = 0; j < N; ++j) {
if(i != j) vec.push_back(make_tuple(P[i] - P[j], i, j));
}
}
sort(vec.begin(), vec.end(), [](tuple<point, int, int> p1, tuple<point, int, int> p2) {
int s1 = shougen(get<0>(p1)), s2 = shougen(get<0>(p2));
if(s1 != s2) return s1 < s2;
return get<0>(p1).cross(get<0>(p2)) > 0;
});
long long ans = 0;
for(tuple<point, int, int> i : vec) {
int pa = get<1>(i), pb = get<2>(i);
int pos = min(inv[pa], inv[pb]);
swap(inv[pa], inv[pb]);
swap(perm[pos], perm[pos + 1]);
long long sum = V[perm[pos]];
for(int j = pos + 1; j <= N; ++j) {
sum += V[perm[j]];
ans = max(ans, sum);
}
}
cout << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
1148 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
9 ms |
1148 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
9 ms |
1148 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
9 ms |
1148 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
1148 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |