#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; bool ok = false;
vector<Fraction>E;
int main() {
cin >> N;
for (int i = 0; i < N; i++) { cin >> X[i] >> Y[i] >> W[i]; if (Y[i] != 0) ok = true; }
E.push_back(Fraction{ 0, 1 });
if (ok == true) {
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:40: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 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
256 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
576 KB |
Output is correct |
2 |
Correct |
25 ms |
512 KB |
Output is correct |
3 |
Correct |
25 ms |
512 KB |
Output is correct |
4 |
Correct |
25 ms |
512 KB |
Output is correct |
5 |
Correct |
25 ms |
512 KB |
Output is correct |
6 |
Correct |
25 ms |
512 KB |
Output is correct |
7 |
Correct |
26 ms |
512 KB |
Output is correct |
8 |
Correct |
25 ms |
556 KB |
Output is correct |
9 |
Correct |
26 ms |
512 KB |
Output is correct |
10 |
Correct |
26 ms |
584 KB |
Output is correct |
11 |
Correct |
3 ms |
384 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 |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
256 KB |
Output is correct |
20 |
Correct |
2 ms |
256 KB |
Output is correct |
21 |
Correct |
23 ms |
576 KB |
Output is correct |
22 |
Correct |
24 ms |
484 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 |
24 ms |
576 KB |
Output is correct |
27 |
Correct |
24 ms |
512 KB |
Output is correct |
28 |
Correct |
23 ms |
512 KB |
Output is correct |
29 |
Correct |
24 ms |
512 KB |
Output is correct |
30 |
Correct |
24 ms |
576 KB |
Output is correct |
31 |
Correct |
24 ms |
512 KB |
Output is correct |
32 |
Correct |
24 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
576 KB |
Output is correct |
2 |
Correct |
25 ms |
512 KB |
Output is correct |
3 |
Correct |
25 ms |
512 KB |
Output is correct |
4 |
Correct |
25 ms |
512 KB |
Output is correct |
5 |
Correct |
25 ms |
512 KB |
Output is correct |
6 |
Correct |
25 ms |
512 KB |
Output is correct |
7 |
Correct |
26 ms |
512 KB |
Output is correct |
8 |
Correct |
25 ms |
556 KB |
Output is correct |
9 |
Correct |
26 ms |
512 KB |
Output is correct |
10 |
Correct |
26 ms |
584 KB |
Output is correct |
11 |
Correct |
3 ms |
384 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 |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
256 KB |
Output is correct |
20 |
Correct |
2 ms |
256 KB |
Output is correct |
21 |
Correct |
23 ms |
576 KB |
Output is correct |
22 |
Correct |
24 ms |
484 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 |
24 ms |
576 KB |
Output is correct |
27 |
Correct |
24 ms |
512 KB |
Output is correct |
28 |
Correct |
23 ms |
512 KB |
Output is correct |
29 |
Correct |
24 ms |
512 KB |
Output is correct |
30 |
Correct |
24 ms |
576 KB |
Output is correct |
31 |
Correct |
24 ms |
512 KB |
Output is correct |
32 |
Correct |
24 ms |
512 KB |
Output is correct |
33 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
576 KB |
Output is correct |
2 |
Correct |
25 ms |
512 KB |
Output is correct |
3 |
Correct |
25 ms |
512 KB |
Output is correct |
4 |
Correct |
25 ms |
512 KB |
Output is correct |
5 |
Correct |
25 ms |
512 KB |
Output is correct |
6 |
Correct |
25 ms |
512 KB |
Output is correct |
7 |
Correct |
26 ms |
512 KB |
Output is correct |
8 |
Correct |
25 ms |
556 KB |
Output is correct |
9 |
Correct |
26 ms |
512 KB |
Output is correct |
10 |
Correct |
26 ms |
584 KB |
Output is correct |
11 |
Correct |
3 ms |
384 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 |
384 KB |
Output is correct |
17 |
Correct |
2 ms |
384 KB |
Output is correct |
18 |
Correct |
2 ms |
256 KB |
Output is correct |
19 |
Correct |
2 ms |
256 KB |
Output is correct |
20 |
Correct |
2 ms |
256 KB |
Output is correct |
21 |
Correct |
23 ms |
576 KB |
Output is correct |
22 |
Correct |
24 ms |
484 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 |
24 ms |
576 KB |
Output is correct |
27 |
Correct |
24 ms |
512 KB |
Output is correct |
28 |
Correct |
23 ms |
512 KB |
Output is correct |
29 |
Correct |
24 ms |
512 KB |
Output is correct |
30 |
Correct |
24 ms |
576 KB |
Output is correct |
31 |
Correct |
24 ms |
512 KB |
Output is correct |
32 |
Correct |
24 ms |
512 KB |
Output is correct |
33 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
34 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
256 KB |
Output is correct |
12 |
Correct |
2 ms |
384 KB |
Output is correct |
13 |
Correct |
2 ms |
256 KB |
Output is correct |
14 |
Correct |
2 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
26 ms |
576 KB |
Output is correct |
17 |
Correct |
25 ms |
512 KB |
Output is correct |
18 |
Correct |
25 ms |
512 KB |
Output is correct |
19 |
Correct |
25 ms |
512 KB |
Output is correct |
20 |
Correct |
25 ms |
512 KB |
Output is correct |
21 |
Correct |
25 ms |
512 KB |
Output is correct |
22 |
Correct |
26 ms |
512 KB |
Output is correct |
23 |
Correct |
25 ms |
556 KB |
Output is correct |
24 |
Correct |
26 ms |
512 KB |
Output is correct |
25 |
Correct |
26 ms |
584 KB |
Output is correct |
26 |
Correct |
3 ms |
384 KB |
Output is correct |
27 |
Correct |
2 ms |
256 KB |
Output is correct |
28 |
Correct |
2 ms |
256 KB |
Output is correct |
29 |
Correct |
2 ms |
256 KB |
Output is correct |
30 |
Correct |
2 ms |
256 KB |
Output is correct |
31 |
Correct |
2 ms |
384 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |
33 |
Correct |
2 ms |
256 KB |
Output is correct |
34 |
Correct |
2 ms |
256 KB |
Output is correct |
35 |
Correct |
2 ms |
256 KB |
Output is correct |
36 |
Correct |
23 ms |
576 KB |
Output is correct |
37 |
Correct |
24 ms |
484 KB |
Output is correct |
38 |
Correct |
23 ms |
512 KB |
Output is correct |
39 |
Correct |
23 ms |
512 KB |
Output is correct |
40 |
Correct |
23 ms |
512 KB |
Output is correct |
41 |
Correct |
24 ms |
576 KB |
Output is correct |
42 |
Correct |
24 ms |
512 KB |
Output is correct |
43 |
Correct |
23 ms |
512 KB |
Output is correct |
44 |
Correct |
24 ms |
512 KB |
Output is correct |
45 |
Correct |
24 ms |
576 KB |
Output is correct |
46 |
Correct |
24 ms |
512 KB |
Output is correct |
47 |
Correct |
24 ms |
512 KB |
Output is correct |
48 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
49 |
Halted |
0 ms |
0 KB |
- |