#include <algorithm>
#include <iostream>
#include <string.h>
#include <cstdlib>
#include <vector>
#include <string>
#include <bitset>
#include <math.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7, INF = 1e18 + 1;
using namespace std;
ll p[1000000], to[10000], n;
struct SegTree
{
ll t[80000][4], start;
ll operator[] (const int& i)
{
return t[i][0];
}
void build (ll n)
{
start = 1;
while (start < n) start <<= 1;
for (ll i = 2 * start - 1; i; i--)
merge (i);
}
void merge (ll node)
{
if (node >= start)
{
t[node][3] = p[node - start];
t[node][2] = max (0LL, p[node - start]);
t[node][1] = max (0LL, p[node - start]);
t[node][0] = max (0LL, p[node - start]);
}
else
{
t[node][3] = t[2 * node][3] + t[2 * node + 1][3];
t[node][2] = max (t[2 * node][3] + t[2 * node + 1][2], t[2 * node][2]);
t[node][1] = max (t[2 * node][1] + t[2 * node + 1][3], t[2 * node + 1][1]);
t[node][0] = max (max (t[2 * node][0], t[2 * node + 1][0]), t[2 * node][1] + t[2 * node + 1][2]);
}
}
void update (ll x, ll d)
{
p[x] = d;
x += start;
while (x)
{
merge (x);
x /= 2;
}
}
} t;
struct point
{
ll x, y, c;
bool operator < (const point& b) const
{
return (y == b.y ? x < b.x : y > b.y);
}
} a[2000];
struct fraction
{
ll a, b;
ll p1, p2;
bool operator < (const fraction& d) const
{
if (!d.b && !b) return a < d.a;
if (!d.b) return true;
if (!b) return false;
return (a * d.b) < (b * d.a);
}
bool operator == (const fraction& d) const
{
if (!b && !d.b) return true;
if (!b || !d.b) return false;
return (a * d.b) == (b * d.a);
}
};
vector <fraction> d;
int main ()
{
cin >> n;
for (ll i = 0; i < n; i++)
scanf ("%lld%lld%lld", &a[i].x, &a[i].y, &a[i].c);
sort (a, a + n);
for (ll i = 0; i < n; i++)
p[i] = a[i].c;
for (ll i = 0; i < n; i++)
for (ll j = i + 1; j < n; j++)
{
ll A = a[i].y - a[j].y;
ll B = a[i].x - a[j].x;
d.push_back ({-B, A, i, j});
to[i] = i;
to[j] = j;
}
sort (d.begin(), d.end());
t.build (n);
ll ans = t[1];
for (ll i = 0; i < d.size (); i++)
{
if (d[i].b == 0) break;
ll l = d[i].p1, r = d[i].p2, p_l = p[to[l]], p_r = p[to[r]];
if (to[l] > to[r]) continue;
t.update (to[r], p_l);
t.update (to[l], p_r);
swap (to[l], to[r]);
/*for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
if (to[i] == j)
cout << "(" << a[j].x << ", " << a[j].y << ") ";
cout << endl;*/
ans = max (ans, t[1]);
}
cout << ans;
}
Compilation message
bulldozer.cpp: In function 'int main()':
bulldozer.cpp:139:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (ll i = 0; i < d.size (); i++)
~~^~~~~~~~~~~
bulldozer.cpp:113:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf ("%lld%lld%lld", &a[i].x, &a[i].y, &a[i].c);
~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
760 KB |
Output is correct |
2 |
Correct |
3 ms |
760 KB |
Output is correct |
3 |
Correct |
3 ms |
760 KB |
Output is correct |
4 |
Correct |
3 ms |
760 KB |
Output is correct |
5 |
Correct |
3 ms |
760 KB |
Output is correct |
6 |
Correct |
3 ms |
760 KB |
Output is correct |
7 |
Correct |
3 ms |
760 KB |
Output is correct |
8 |
Correct |
3 ms |
760 KB |
Output is correct |
9 |
Correct |
3 ms |
760 KB |
Output is correct |
10 |
Correct |
3 ms |
760 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
760 KB |
Output is correct |
2 |
Correct |
3 ms |
760 KB |
Output is correct |
3 |
Correct |
4 ms |
760 KB |
Output is correct |
4 |
Correct |
3 ms |
760 KB |
Output is correct |
5 |
Correct |
4 ms |
760 KB |
Output is correct |
6 |
Correct |
3 ms |
760 KB |
Output is correct |
7 |
Correct |
4 ms |
760 KB |
Output is correct |
8 |
Correct |
3 ms |
764 KB |
Output is correct |
9 |
Correct |
3 ms |
760 KB |
Output is correct |
10 |
Correct |
3 ms |
760 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
380 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
4 ms |
760 KB |
Output is correct |
22 |
Correct |
3 ms |
760 KB |
Output is correct |
23 |
Correct |
3 ms |
760 KB |
Output is correct |
24 |
Correct |
3 ms |
760 KB |
Output is correct |
25 |
Correct |
3 ms |
760 KB |
Output is correct |
26 |
Correct |
3 ms |
760 KB |
Output is correct |
27 |
Correct |
3 ms |
760 KB |
Output is correct |
28 |
Correct |
3 ms |
760 KB |
Output is correct |
29 |
Correct |
3 ms |
760 KB |
Output is correct |
30 |
Correct |
3 ms |
760 KB |
Output is correct |
31 |
Correct |
3 ms |
760 KB |
Output is correct |
32 |
Correct |
3 ms |
760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
760 KB |
Output is correct |
2 |
Correct |
3 ms |
760 KB |
Output is correct |
3 |
Correct |
4 ms |
760 KB |
Output is correct |
4 |
Correct |
3 ms |
760 KB |
Output is correct |
5 |
Correct |
4 ms |
760 KB |
Output is correct |
6 |
Correct |
3 ms |
760 KB |
Output is correct |
7 |
Correct |
4 ms |
760 KB |
Output is correct |
8 |
Correct |
3 ms |
764 KB |
Output is correct |
9 |
Correct |
3 ms |
760 KB |
Output is correct |
10 |
Correct |
3 ms |
760 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
380 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
4 ms |
760 KB |
Output is correct |
22 |
Correct |
3 ms |
760 KB |
Output is correct |
23 |
Correct |
3 ms |
760 KB |
Output is correct |
24 |
Correct |
3 ms |
760 KB |
Output is correct |
25 |
Correct |
3 ms |
760 KB |
Output is correct |
26 |
Correct |
3 ms |
760 KB |
Output is correct |
27 |
Correct |
3 ms |
760 KB |
Output is correct |
28 |
Correct |
3 ms |
760 KB |
Output is correct |
29 |
Correct |
3 ms |
760 KB |
Output is correct |
30 |
Correct |
3 ms |
760 KB |
Output is correct |
31 |
Correct |
3 ms |
760 KB |
Output is correct |
32 |
Correct |
3 ms |
760 KB |
Output is correct |
33 |
Correct |
717 ms |
66204 KB |
Output is correct |
34 |
Correct |
724 ms |
66328 KB |
Output is correct |
35 |
Correct |
731 ms |
66300 KB |
Output is correct |
36 |
Correct |
735 ms |
66328 KB |
Output is correct |
37 |
Correct |
724 ms |
66328 KB |
Output is correct |
38 |
Correct |
819 ms |
66288 KB |
Output is correct |
39 |
Correct |
744 ms |
66328 KB |
Output is correct |
40 |
Correct |
738 ms |
66328 KB |
Output is correct |
41 |
Correct |
716 ms |
66328 KB |
Output is correct |
42 |
Correct |
725 ms |
66204 KB |
Output is correct |
43 |
Correct |
722 ms |
66200 KB |
Output is correct |
44 |
Correct |
748 ms |
66328 KB |
Output is correct |
45 |
Correct |
742 ms |
66328 KB |
Output is correct |
46 |
Correct |
750 ms |
66200 KB |
Output is correct |
47 |
Correct |
727 ms |
66328 KB |
Output is correct |
48 |
Correct |
721 ms |
66200 KB |
Output is correct |
49 |
Correct |
708 ms |
66200 KB |
Output is correct |
50 |
Correct |
721 ms |
66328 KB |
Output is correct |
51 |
Correct |
715 ms |
66328 KB |
Output is correct |
52 |
Correct |
710 ms |
66328 KB |
Output is correct |
53 |
Correct |
702 ms |
66200 KB |
Output is correct |
54 |
Correct |
717 ms |
66200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
760 KB |
Output is correct |
2 |
Correct |
3 ms |
760 KB |
Output is correct |
3 |
Correct |
4 ms |
760 KB |
Output is correct |
4 |
Correct |
3 ms |
760 KB |
Output is correct |
5 |
Correct |
4 ms |
760 KB |
Output is correct |
6 |
Correct |
3 ms |
760 KB |
Output is correct |
7 |
Correct |
4 ms |
760 KB |
Output is correct |
8 |
Correct |
3 ms |
764 KB |
Output is correct |
9 |
Correct |
3 ms |
760 KB |
Output is correct |
10 |
Correct |
3 ms |
760 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
2 ms |
376 KB |
Output is correct |
17 |
Correct |
2 ms |
380 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
376 KB |
Output is correct |
21 |
Correct |
4 ms |
760 KB |
Output is correct |
22 |
Correct |
3 ms |
760 KB |
Output is correct |
23 |
Correct |
3 ms |
760 KB |
Output is correct |
24 |
Correct |
3 ms |
760 KB |
Output is correct |
25 |
Correct |
3 ms |
760 KB |
Output is correct |
26 |
Correct |
3 ms |
760 KB |
Output is correct |
27 |
Correct |
3 ms |
760 KB |
Output is correct |
28 |
Correct |
3 ms |
760 KB |
Output is correct |
29 |
Correct |
3 ms |
760 KB |
Output is correct |
30 |
Correct |
3 ms |
760 KB |
Output is correct |
31 |
Correct |
3 ms |
760 KB |
Output is correct |
32 |
Correct |
3 ms |
760 KB |
Output is correct |
33 |
Correct |
717 ms |
66204 KB |
Output is correct |
34 |
Correct |
724 ms |
66328 KB |
Output is correct |
35 |
Correct |
731 ms |
66300 KB |
Output is correct |
36 |
Correct |
735 ms |
66328 KB |
Output is correct |
37 |
Correct |
724 ms |
66328 KB |
Output is correct |
38 |
Correct |
819 ms |
66288 KB |
Output is correct |
39 |
Correct |
744 ms |
66328 KB |
Output is correct |
40 |
Correct |
738 ms |
66328 KB |
Output is correct |
41 |
Correct |
716 ms |
66328 KB |
Output is correct |
42 |
Correct |
725 ms |
66204 KB |
Output is correct |
43 |
Correct |
722 ms |
66200 KB |
Output is correct |
44 |
Correct |
748 ms |
66328 KB |
Output is correct |
45 |
Correct |
742 ms |
66328 KB |
Output is correct |
46 |
Correct |
750 ms |
66200 KB |
Output is correct |
47 |
Correct |
727 ms |
66328 KB |
Output is correct |
48 |
Correct |
721 ms |
66200 KB |
Output is correct |
49 |
Correct |
708 ms |
66200 KB |
Output is correct |
50 |
Correct |
721 ms |
66328 KB |
Output is correct |
51 |
Correct |
715 ms |
66328 KB |
Output is correct |
52 |
Correct |
710 ms |
66328 KB |
Output is correct |
53 |
Correct |
702 ms |
66200 KB |
Output is correct |
54 |
Correct |
717 ms |
66200 KB |
Output is correct |
55 |
Correct |
719 ms |
66236 KB |
Output is correct |
56 |
Correct |
727 ms |
66200 KB |
Output is correct |
57 |
Correct |
718 ms |
66264 KB |
Output is correct |
58 |
Correct |
720 ms |
66200 KB |
Output is correct |
59 |
Correct |
747 ms |
66312 KB |
Output is correct |
60 |
Correct |
736 ms |
66300 KB |
Output is correct |
61 |
Correct |
749 ms |
66280 KB |
Output is correct |
62 |
Correct |
774 ms |
66328 KB |
Output is correct |
63 |
Correct |
773 ms |
66252 KB |
Output is correct |
64 |
Correct |
752 ms |
66328 KB |
Output is correct |
65 |
Correct |
724 ms |
66200 KB |
Output is correct |
66 |
Correct |
713 ms |
66200 KB |
Output is correct |
67 |
Correct |
725 ms |
66352 KB |
Output is correct |
68 |
Correct |
729 ms |
66328 KB |
Output is correct |
69 |
Correct |
733 ms |
66328 KB |
Output is correct |
70 |
Correct |
740 ms |
66328 KB |
Output is correct |
71 |
Correct |
727 ms |
66328 KB |
Output is correct |
72 |
Correct |
733 ms |
66200 KB |
Output is correct |
73 |
Correct |
723 ms |
66328 KB |
Output is correct |
74 |
Correct |
721 ms |
66204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
760 KB |
Output is correct |
2 |
Correct |
3 ms |
760 KB |
Output is correct |
3 |
Correct |
3 ms |
760 KB |
Output is correct |
4 |
Correct |
3 ms |
760 KB |
Output is correct |
5 |
Correct |
3 ms |
760 KB |
Output is correct |
6 |
Correct |
3 ms |
760 KB |
Output is correct |
7 |
Correct |
3 ms |
760 KB |
Output is correct |
8 |
Correct |
3 ms |
760 KB |
Output is correct |
9 |
Correct |
3 ms |
760 KB |
Output is correct |
10 |
Correct |
3 ms |
760 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
2 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
3 ms |
760 KB |
Output is correct |
17 |
Correct |
3 ms |
760 KB |
Output is correct |
18 |
Correct |
4 ms |
760 KB |
Output is correct |
19 |
Correct |
3 ms |
760 KB |
Output is correct |
20 |
Correct |
4 ms |
760 KB |
Output is correct |
21 |
Correct |
3 ms |
760 KB |
Output is correct |
22 |
Correct |
4 ms |
760 KB |
Output is correct |
23 |
Correct |
3 ms |
764 KB |
Output is correct |
24 |
Correct |
3 ms |
760 KB |
Output is correct |
25 |
Correct |
3 ms |
760 KB |
Output is correct |
26 |
Correct |
2 ms |
376 KB |
Output is correct |
27 |
Correct |
2 ms |
376 KB |
Output is correct |
28 |
Correct |
2 ms |
376 KB |
Output is correct |
29 |
Correct |
2 ms |
376 KB |
Output is correct |
30 |
Correct |
2 ms |
376 KB |
Output is correct |
31 |
Correct |
2 ms |
376 KB |
Output is correct |
32 |
Correct |
2 ms |
380 KB |
Output is correct |
33 |
Correct |
2 ms |
376 KB |
Output is correct |
34 |
Correct |
2 ms |
376 KB |
Output is correct |
35 |
Correct |
2 ms |
376 KB |
Output is correct |
36 |
Correct |
4 ms |
760 KB |
Output is correct |
37 |
Correct |
3 ms |
760 KB |
Output is correct |
38 |
Correct |
3 ms |
760 KB |
Output is correct |
39 |
Correct |
3 ms |
760 KB |
Output is correct |
40 |
Correct |
3 ms |
760 KB |
Output is correct |
41 |
Correct |
3 ms |
760 KB |
Output is correct |
42 |
Correct |
3 ms |
760 KB |
Output is correct |
43 |
Correct |
3 ms |
760 KB |
Output is correct |
44 |
Correct |
3 ms |
760 KB |
Output is correct |
45 |
Correct |
3 ms |
760 KB |
Output is correct |
46 |
Correct |
3 ms |
760 KB |
Output is correct |
47 |
Correct |
3 ms |
760 KB |
Output is correct |
48 |
Correct |
717 ms |
66204 KB |
Output is correct |
49 |
Correct |
724 ms |
66328 KB |
Output is correct |
50 |
Correct |
731 ms |
66300 KB |
Output is correct |
51 |
Correct |
735 ms |
66328 KB |
Output is correct |
52 |
Correct |
724 ms |
66328 KB |
Output is correct |
53 |
Correct |
819 ms |
66288 KB |
Output is correct |
54 |
Correct |
744 ms |
66328 KB |
Output is correct |
55 |
Correct |
738 ms |
66328 KB |
Output is correct |
56 |
Correct |
716 ms |
66328 KB |
Output is correct |
57 |
Correct |
725 ms |
66204 KB |
Output is correct |
58 |
Correct |
722 ms |
66200 KB |
Output is correct |
59 |
Correct |
748 ms |
66328 KB |
Output is correct |
60 |
Correct |
742 ms |
66328 KB |
Output is correct |
61 |
Correct |
750 ms |
66200 KB |
Output is correct |
62 |
Correct |
727 ms |
66328 KB |
Output is correct |
63 |
Correct |
721 ms |
66200 KB |
Output is correct |
64 |
Correct |
708 ms |
66200 KB |
Output is correct |
65 |
Correct |
721 ms |
66328 KB |
Output is correct |
66 |
Correct |
715 ms |
66328 KB |
Output is correct |
67 |
Correct |
710 ms |
66328 KB |
Output is correct |
68 |
Correct |
702 ms |
66200 KB |
Output is correct |
69 |
Correct |
717 ms |
66200 KB |
Output is correct |
70 |
Correct |
719 ms |
66236 KB |
Output is correct |
71 |
Correct |
727 ms |
66200 KB |
Output is correct |
72 |
Correct |
718 ms |
66264 KB |
Output is correct |
73 |
Correct |
720 ms |
66200 KB |
Output is correct |
74 |
Correct |
747 ms |
66312 KB |
Output is correct |
75 |
Correct |
736 ms |
66300 KB |
Output is correct |
76 |
Correct |
749 ms |
66280 KB |
Output is correct |
77 |
Correct |
774 ms |
66328 KB |
Output is correct |
78 |
Correct |
773 ms |
66252 KB |
Output is correct |
79 |
Correct |
752 ms |
66328 KB |
Output is correct |
80 |
Correct |
724 ms |
66200 KB |
Output is correct |
81 |
Correct |
713 ms |
66200 KB |
Output is correct |
82 |
Correct |
725 ms |
66352 KB |
Output is correct |
83 |
Correct |
729 ms |
66328 KB |
Output is correct |
84 |
Correct |
733 ms |
66328 KB |
Output is correct |
85 |
Correct |
740 ms |
66328 KB |
Output is correct |
86 |
Correct |
727 ms |
66328 KB |
Output is correct |
87 |
Correct |
733 ms |
66200 KB |
Output is correct |
88 |
Correct |
723 ms |
66328 KB |
Output is correct |
89 |
Correct |
721 ms |
66204 KB |
Output is correct |
90 |
Correct |
799 ms |
66312 KB |
Output is correct |
91 |
Correct |
741 ms |
66328 KB |
Output is correct |
92 |
Correct |
728 ms |
66220 KB |
Output is correct |
93 |
Correct |
730 ms |
66312 KB |
Output is correct |
94 |
Correct |
754 ms |
66200 KB |
Output is correct |
95 |
Correct |
724 ms |
66328 KB |
Output is correct |
96 |
Correct |
739 ms |
66328 KB |
Output is correct |
97 |
Correct |
739 ms |
66200 KB |
Output is correct |
98 |
Correct |
712 ms |
66240 KB |
Output is correct |
99 |
Correct |
726 ms |
66328 KB |
Output is correct |
100 |
Incorrect |
453 ms |
66200 KB |
Output isn't correct |
101 |
Halted |
0 ms |
0 KB |
- |