#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct Fraction {
public:
long long cx, cy;
};
long long gcd(long long a, long long b) {
if (b == 0) return a;
return gcd(b, a%b);
}
Fraction teisei(Fraction A) {
long long E = gcd(A.cx, A.cy);
A.cx /= E; A.cy /= E;
return A;
}
long long N, X[109], Y[109], W[109], ans;
vector<Fraction>E;
int main() {
cin >> N;
for (int i = 0; i < N; i++) cin >> X[i] >> Y[i] >> W[i];
for (int i = 0; i < N; i++) {
for (int j = i + 1; j < N; j++) E.push_back(teisei(Fraction{ X[j] - X[i],Y[j] - Y[i] }));
}
for (Fraction R : E) {
vector<pair<long long, int>>vec;
for (int i = 0; i < N; i++) vec.push_back(make_pair(X[i] * -R.cy + Y[i] * R.cx, i));
sort(vec.begin(), vec.end());
long long sum = 0, minx = 0;
for (int i = 0; i < vec.size(); i++) {
sum += W[vec[i].second]; minx = min(minx, sum);
ans = max(ans, sum - minx);
}
}
cout << ans << endl;
return 0;
}
Compilation message
bulldozer.cpp: In function 'int main()':
bulldozer.cpp:37:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < vec.size(); i++) {
~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
580 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
512 KB |
Output is correct |
2 |
Correct |
25 ms |
512 KB |
Output is correct |
3 |
Correct |
26 ms |
512 KB |
Output is correct |
4 |
Correct |
26 ms |
560 KB |
Output is correct |
5 |
Correct |
25 ms |
512 KB |
Output is correct |
6 |
Correct |
25 ms |
556 KB |
Output is correct |
7 |
Correct |
26 ms |
572 KB |
Output is correct |
8 |
Correct |
25 ms |
512 KB |
Output is correct |
9 |
Correct |
25 ms |
484 KB |
Output is correct |
10 |
Correct |
25 ms |
576 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
512 KB |
Output is correct |
2 |
Correct |
25 ms |
512 KB |
Output is correct |
3 |
Correct |
26 ms |
512 KB |
Output is correct |
4 |
Correct |
26 ms |
560 KB |
Output is correct |
5 |
Correct |
25 ms |
512 KB |
Output is correct |
6 |
Correct |
25 ms |
556 KB |
Output is correct |
7 |
Correct |
26 ms |
572 KB |
Output is correct |
8 |
Correct |
25 ms |
512 KB |
Output is correct |
9 |
Correct |
25 ms |
484 KB |
Output is correct |
10 |
Correct |
25 ms |
576 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
25 ms |
512 KB |
Output is correct |
2 |
Correct |
25 ms |
512 KB |
Output is correct |
3 |
Correct |
26 ms |
512 KB |
Output is correct |
4 |
Correct |
26 ms |
560 KB |
Output is correct |
5 |
Correct |
25 ms |
512 KB |
Output is correct |
6 |
Correct |
25 ms |
556 KB |
Output is correct |
7 |
Correct |
26 ms |
572 KB |
Output is correct |
8 |
Correct |
25 ms |
512 KB |
Output is correct |
9 |
Correct |
25 ms |
484 KB |
Output is correct |
10 |
Correct |
25 ms |
576 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
13 ms |
580 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |