#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] }));
}
E.push_back(Fraction{ 1, 0 });
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:38: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 |
14 ms |
580 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 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 |
656 KB |
Output is correct |
5 |
Correct |
26 ms |
512 KB |
Output is correct |
6 |
Correct |
25 ms |
640 KB |
Output is correct |
7 |
Correct |
25 ms |
512 KB |
Output is correct |
8 |
Correct |
25 ms |
512 KB |
Output is correct |
9 |
Correct |
27 ms |
512 KB |
Output is correct |
10 |
Correct |
26 ms |
556 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
256 KB |
Output is correct |
13 |
Correct |
2 ms |
256 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
2 ms |
256 KB |
Output is correct |
16 |
Correct |
2 ms |
256 KB |
Output is correct |
17 |
Correct |
4 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
252 KB |
Output is correct |
19 |
Correct |
2 ms |
256 KB |
Output is correct |
20 |
Correct |
2 ms |
256 KB |
Output is correct |
21 |
Correct |
24 ms |
632 KB |
Output is correct |
22 |
Correct |
23 ms |
584 KB |
Output is correct |
23 |
Correct |
23 ms |
512 KB |
Output is correct |
24 |
Correct |
23 ms |
512 KB |
Output is correct |
25 |
Correct |
23 ms |
512 KB |
Output is correct |
26 |
Correct |
23 ms |
580 KB |
Output is correct |
27 |
Correct |
24 ms |
512 KB |
Output is correct |
28 |
Correct |
24 ms |
512 KB |
Output is correct |
29 |
Correct |
24 ms |
512 KB |
Output is correct |
30 |
Correct |
26 ms |
588 KB |
Output is correct |
31 |
Correct |
24 ms |
512 KB |
Output is correct |
32 |
Correct |
24 ms |
576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 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 |
656 KB |
Output is correct |
5 |
Correct |
26 ms |
512 KB |
Output is correct |
6 |
Correct |
25 ms |
640 KB |
Output is correct |
7 |
Correct |
25 ms |
512 KB |
Output is correct |
8 |
Correct |
25 ms |
512 KB |
Output is correct |
9 |
Correct |
27 ms |
512 KB |
Output is correct |
10 |
Correct |
26 ms |
556 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
256 KB |
Output is correct |
13 |
Correct |
2 ms |
256 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
2 ms |
256 KB |
Output is correct |
16 |
Correct |
2 ms |
256 KB |
Output is correct |
17 |
Correct |
4 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
252 KB |
Output is correct |
19 |
Correct |
2 ms |
256 KB |
Output is correct |
20 |
Correct |
2 ms |
256 KB |
Output is correct |
21 |
Correct |
24 ms |
632 KB |
Output is correct |
22 |
Correct |
23 ms |
584 KB |
Output is correct |
23 |
Correct |
23 ms |
512 KB |
Output is correct |
24 |
Correct |
23 ms |
512 KB |
Output is correct |
25 |
Correct |
23 ms |
512 KB |
Output is correct |
26 |
Correct |
23 ms |
580 KB |
Output is correct |
27 |
Correct |
24 ms |
512 KB |
Output is correct |
28 |
Correct |
24 ms |
512 KB |
Output is correct |
29 |
Correct |
24 ms |
512 KB |
Output is correct |
30 |
Correct |
26 ms |
588 KB |
Output is correct |
31 |
Correct |
24 ms |
512 KB |
Output is correct |
32 |
Correct |
24 ms |
576 KB |
Output is correct |
33 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 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 |
656 KB |
Output is correct |
5 |
Correct |
26 ms |
512 KB |
Output is correct |
6 |
Correct |
25 ms |
640 KB |
Output is correct |
7 |
Correct |
25 ms |
512 KB |
Output is correct |
8 |
Correct |
25 ms |
512 KB |
Output is correct |
9 |
Correct |
27 ms |
512 KB |
Output is correct |
10 |
Correct |
26 ms |
556 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
256 KB |
Output is correct |
13 |
Correct |
2 ms |
256 KB |
Output is correct |
14 |
Correct |
2 ms |
256 KB |
Output is correct |
15 |
Correct |
2 ms |
256 KB |
Output is correct |
16 |
Correct |
2 ms |
256 KB |
Output is correct |
17 |
Correct |
4 ms |
256 KB |
Output is correct |
18 |
Correct |
2 ms |
252 KB |
Output is correct |
19 |
Correct |
2 ms |
256 KB |
Output is correct |
20 |
Correct |
2 ms |
256 KB |
Output is correct |
21 |
Correct |
24 ms |
632 KB |
Output is correct |
22 |
Correct |
23 ms |
584 KB |
Output is correct |
23 |
Correct |
23 ms |
512 KB |
Output is correct |
24 |
Correct |
23 ms |
512 KB |
Output is correct |
25 |
Correct |
23 ms |
512 KB |
Output is correct |
26 |
Correct |
23 ms |
580 KB |
Output is correct |
27 |
Correct |
24 ms |
512 KB |
Output is correct |
28 |
Correct |
24 ms |
512 KB |
Output is correct |
29 |
Correct |
24 ms |
512 KB |
Output is correct |
30 |
Correct |
26 ms |
588 KB |
Output is correct |
31 |
Correct |
24 ms |
512 KB |
Output is correct |
32 |
Correct |
24 ms |
576 KB |
Output is correct |
33 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
14 ms |
580 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |