답안 #590618

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
590618 2022-07-06T07:35:42 Z 장태환(#8413) Bulldozer (JOI17_bulldozer) C++17
100 / 100
719 ms 66568 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
int x[2010];
int y[2010];
int c[2010];
int cp[2010];
struct node {
	int l, r, s, ma;
	node()
	{
		l = r = s = ma = 0;
	}
	node(int a, int b, int c, int d)
	{
		l = a;
		r = b;
		s = c;
		ma = d;
	}
	node(int a)
	{
		l = r = s = ma = a;
		ma = max(ma, 0LL);
	}
	node operator+(node x)
	{
		return { max(l,s + x.l),max(x.r,r + x.s),s + x.s,max({ma,x.ma,r + x.l}) };
	}
};
node stree[1 << 13];
int treeN;
void upd(int n, int a)
{
	n += treeN;
	stree[n] = node(a);
	while (n > 1)
	{
		n /= 2;
		stree[n] = stree[n * 2] + stree[n * 2 + 1];
	}
}
struct vec
{
	int xx, yy;
	int sa, sb;
	bool operator<(vec b)
	{
		if(xx*b.yy!=yy*b.xx)
			return xx * b.yy < yy * b.xx;
		if (sa != b.sa)
		{
			return make_pair(x[sa],-y[sa] ) < make_pair(x[b.sa], -y[b.sa]);
		}
		return make_pair(x[sb], -y[sb]) > make_pair(x[b.sb], -y[b.sb]);
	}
	bool operator==(vec b)
	{
		return xx * b.yy == yy * b.xx;
	}
};
struct pnt
{
	int x, y, ind, cst;
	bool operator<(pnt b)
	{
		return make_pair(x, -y) < make_pair(b.x, -b.y);
	}
};
vector<vec>od;

vector<pnt> ls;
signed main()
{
	int N;
	cin >> N;
	int i;
	for (i = 0; i < N; i++)
	{
		cin >> x[i] >> y[i] >> c[i];
		ls.push_back({ x[i],y[i],i,c[i] });
	}
	for (treeN = 1; treeN < N; treeN *= 2);
	sort(ls.begin(), ls.end());
	for (i = 0; i < N; i++)
	{
		upd(i, ls[i].cst);
		cp[ls[i].ind] = i;
		int j;
		for (j = i + 1; j < N; j++)
		{
			od.push_back({ ls[j].x - ls[i].x,ls[j].y - ls[i].y,ls[i].ind,ls[j].ind });
		}
	}
	sort(od.begin(), od.end());
	vec bef;
	int ans = stree[1].ma;
	for (i = 0; i < od.size(); i++)
	{
		if (i && !(bef == od[i]))
		{
			ans = max(ans, stree[1].ma);
		}
		if (cp[od[i].sa] < cp[od[i].sb])
		{
			upd(cp[od[i].sa], ls[cp[od[i].sb]].cst);
			upd(cp[od[i].sb], ls[cp[od[i].sa]].cst);
			swap(ls[cp[od[i].sa]], ls[cp[od[i].sb]]);
			swap(cp[od[i].sa], cp[od[i].sb]);
		}



		bef = od[i];
	}
	ans = max(ans, stree[1].ma);
	cout << ans;
}

Compilation message

bulldozer.cpp: In function 'int main()':
bulldozer.cpp:98:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<vec>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   98 |  for (i = 0; i < od.size(); i++)
      |              ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 852 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 852 KB Output is correct
4 Correct 1 ms 852 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 852 KB Output is correct
8 Correct 1 ms 852 KB Output is correct
9 Correct 1 ms 852 KB Output is correct
10 Correct 1 ms 980 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 0 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 896 KB Output is correct
2 Correct 1 ms 852 KB Output is correct
3 Correct 2 ms 852 KB Output is correct
4 Correct 1 ms 852 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 2 ms 852 KB Output is correct
7 Correct 2 ms 936 KB Output is correct
8 Correct 2 ms 980 KB Output is correct
9 Correct 2 ms 852 KB Output is correct
10 Correct 2 ms 980 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 0 ms 468 KB Output is correct
13 Correct 0 ms 468 KB Output is correct
14 Correct 0 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 2 ms 852 KB Output is correct
22 Correct 2 ms 852 KB Output is correct
23 Correct 2 ms 852 KB Output is correct
24 Correct 1 ms 980 KB Output is correct
25 Correct 1 ms 852 KB Output is correct
26 Correct 2 ms 852 KB Output is correct
27 Correct 1 ms 852 KB Output is correct
28 Correct 2 ms 852 KB Output is correct
29 Correct 1 ms 852 KB Output is correct
30 Correct 1 ms 852 KB Output is correct
31 Correct 2 ms 852 KB Output is correct
32 Correct 2 ms 980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 896 KB Output is correct
2 Correct 1 ms 852 KB Output is correct
3 Correct 2 ms 852 KB Output is correct
4 Correct 1 ms 852 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 2 ms 852 KB Output is correct
7 Correct 2 ms 936 KB Output is correct
8 Correct 2 ms 980 KB Output is correct
9 Correct 2 ms 852 KB Output is correct
10 Correct 2 ms 980 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 0 ms 468 KB Output is correct
13 Correct 0 ms 468 KB Output is correct
14 Correct 0 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 2 ms 852 KB Output is correct
22 Correct 2 ms 852 KB Output is correct
23 Correct 2 ms 852 KB Output is correct
24 Correct 1 ms 980 KB Output is correct
25 Correct 1 ms 852 KB Output is correct
26 Correct 2 ms 852 KB Output is correct
27 Correct 1 ms 852 KB Output is correct
28 Correct 2 ms 852 KB Output is correct
29 Correct 1 ms 852 KB Output is correct
30 Correct 1 ms 852 KB Output is correct
31 Correct 2 ms 852 KB Output is correct
32 Correct 2 ms 980 KB Output is correct
33 Correct 586 ms 66488 KB Output is correct
34 Correct 572 ms 66380 KB Output is correct
35 Correct 587 ms 66448 KB Output is correct
36 Correct 560 ms 66376 KB Output is correct
37 Correct 561 ms 66468 KB Output is correct
38 Correct 580 ms 66512 KB Output is correct
39 Correct 550 ms 66464 KB Output is correct
40 Correct 579 ms 66416 KB Output is correct
41 Correct 584 ms 66476 KB Output is correct
42 Correct 556 ms 66444 KB Output is correct
43 Correct 549 ms 66436 KB Output is correct
44 Correct 546 ms 66424 KB Output is correct
45 Correct 565 ms 66444 KB Output is correct
46 Correct 550 ms 66444 KB Output is correct
47 Correct 539 ms 66524 KB Output is correct
48 Correct 549 ms 66384 KB Output is correct
49 Correct 553 ms 66412 KB Output is correct
50 Correct 555 ms 66448 KB Output is correct
51 Correct 557 ms 66376 KB Output is correct
52 Correct 551 ms 66412 KB Output is correct
53 Correct 550 ms 66460 KB Output is correct
54 Correct 544 ms 66444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 896 KB Output is correct
2 Correct 1 ms 852 KB Output is correct
3 Correct 2 ms 852 KB Output is correct
4 Correct 1 ms 852 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 2 ms 852 KB Output is correct
7 Correct 2 ms 936 KB Output is correct
8 Correct 2 ms 980 KB Output is correct
9 Correct 2 ms 852 KB Output is correct
10 Correct 2 ms 980 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 0 ms 468 KB Output is correct
13 Correct 0 ms 468 KB Output is correct
14 Correct 0 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 1 ms 468 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 2 ms 852 KB Output is correct
22 Correct 2 ms 852 KB Output is correct
23 Correct 2 ms 852 KB Output is correct
24 Correct 1 ms 980 KB Output is correct
25 Correct 1 ms 852 KB Output is correct
26 Correct 2 ms 852 KB Output is correct
27 Correct 1 ms 852 KB Output is correct
28 Correct 2 ms 852 KB Output is correct
29 Correct 1 ms 852 KB Output is correct
30 Correct 1 ms 852 KB Output is correct
31 Correct 2 ms 852 KB Output is correct
32 Correct 2 ms 980 KB Output is correct
33 Correct 586 ms 66488 KB Output is correct
34 Correct 572 ms 66380 KB Output is correct
35 Correct 587 ms 66448 KB Output is correct
36 Correct 560 ms 66376 KB Output is correct
37 Correct 561 ms 66468 KB Output is correct
38 Correct 580 ms 66512 KB Output is correct
39 Correct 550 ms 66464 KB Output is correct
40 Correct 579 ms 66416 KB Output is correct
41 Correct 584 ms 66476 KB Output is correct
42 Correct 556 ms 66444 KB Output is correct
43 Correct 549 ms 66436 KB Output is correct
44 Correct 546 ms 66424 KB Output is correct
45 Correct 565 ms 66444 KB Output is correct
46 Correct 550 ms 66444 KB Output is correct
47 Correct 539 ms 66524 KB Output is correct
48 Correct 549 ms 66384 KB Output is correct
49 Correct 553 ms 66412 KB Output is correct
50 Correct 555 ms 66448 KB Output is correct
51 Correct 557 ms 66376 KB Output is correct
52 Correct 551 ms 66412 KB Output is correct
53 Correct 550 ms 66460 KB Output is correct
54 Correct 544 ms 66444 KB Output is correct
55 Correct 545 ms 66440 KB Output is correct
56 Correct 554 ms 66388 KB Output is correct
57 Correct 567 ms 66416 KB Output is correct
58 Correct 560 ms 66512 KB Output is correct
59 Correct 545 ms 66452 KB Output is correct
60 Correct 561 ms 66448 KB Output is correct
61 Correct 542 ms 66412 KB Output is correct
62 Correct 563 ms 66444 KB Output is correct
63 Correct 563 ms 66508 KB Output is correct
64 Correct 545 ms 66444 KB Output is correct
65 Correct 551 ms 66444 KB Output is correct
66 Correct 580 ms 66436 KB Output is correct
67 Correct 542 ms 66412 KB Output is correct
68 Correct 560 ms 66444 KB Output is correct
69 Correct 554 ms 66464 KB Output is correct
70 Correct 540 ms 66448 KB Output is correct
71 Correct 561 ms 66436 KB Output is correct
72 Correct 580 ms 66468 KB Output is correct
73 Correct 543 ms 66492 KB Output is correct
74 Correct 581 ms 66384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 852 KB Output is correct
2 Correct 1 ms 980 KB Output is correct
3 Correct 1 ms 852 KB Output is correct
4 Correct 1 ms 852 KB Output is correct
5 Correct 1 ms 980 KB Output is correct
6 Correct 1 ms 980 KB Output is correct
7 Correct 1 ms 852 KB Output is correct
8 Correct 1 ms 852 KB Output is correct
9 Correct 1 ms 852 KB Output is correct
10 Correct 1 ms 980 KB Output is correct
11 Correct 0 ms 468 KB Output is correct
12 Correct 1 ms 468 KB Output is correct
13 Correct 0 ms 468 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 468 KB Output is correct
16 Correct 2 ms 896 KB Output is correct
17 Correct 1 ms 852 KB Output is correct
18 Correct 2 ms 852 KB Output is correct
19 Correct 1 ms 852 KB Output is correct
20 Correct 1 ms 980 KB Output is correct
21 Correct 2 ms 852 KB Output is correct
22 Correct 2 ms 936 KB Output is correct
23 Correct 2 ms 980 KB Output is correct
24 Correct 2 ms 852 KB Output is correct
25 Correct 2 ms 980 KB Output is correct
26 Correct 0 ms 468 KB Output is correct
27 Correct 0 ms 468 KB Output is correct
28 Correct 0 ms 468 KB Output is correct
29 Correct 0 ms 468 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 1 ms 468 KB Output is correct
34 Correct 1 ms 468 KB Output is correct
35 Correct 1 ms 468 KB Output is correct
36 Correct 2 ms 852 KB Output is correct
37 Correct 2 ms 852 KB Output is correct
38 Correct 2 ms 852 KB Output is correct
39 Correct 1 ms 980 KB Output is correct
40 Correct 1 ms 852 KB Output is correct
41 Correct 2 ms 852 KB Output is correct
42 Correct 1 ms 852 KB Output is correct
43 Correct 2 ms 852 KB Output is correct
44 Correct 1 ms 852 KB Output is correct
45 Correct 1 ms 852 KB Output is correct
46 Correct 2 ms 852 KB Output is correct
47 Correct 2 ms 980 KB Output is correct
48 Correct 586 ms 66488 KB Output is correct
49 Correct 572 ms 66380 KB Output is correct
50 Correct 587 ms 66448 KB Output is correct
51 Correct 560 ms 66376 KB Output is correct
52 Correct 561 ms 66468 KB Output is correct
53 Correct 580 ms 66512 KB Output is correct
54 Correct 550 ms 66464 KB Output is correct
55 Correct 579 ms 66416 KB Output is correct
56 Correct 584 ms 66476 KB Output is correct
57 Correct 556 ms 66444 KB Output is correct
58 Correct 549 ms 66436 KB Output is correct
59 Correct 546 ms 66424 KB Output is correct
60 Correct 565 ms 66444 KB Output is correct
61 Correct 550 ms 66444 KB Output is correct
62 Correct 539 ms 66524 KB Output is correct
63 Correct 549 ms 66384 KB Output is correct
64 Correct 553 ms 66412 KB Output is correct
65 Correct 555 ms 66448 KB Output is correct
66 Correct 557 ms 66376 KB Output is correct
67 Correct 551 ms 66412 KB Output is correct
68 Correct 550 ms 66460 KB Output is correct
69 Correct 544 ms 66444 KB Output is correct
70 Correct 545 ms 66440 KB Output is correct
71 Correct 554 ms 66388 KB Output is correct
72 Correct 567 ms 66416 KB Output is correct
73 Correct 560 ms 66512 KB Output is correct
74 Correct 545 ms 66452 KB Output is correct
75 Correct 561 ms 66448 KB Output is correct
76 Correct 542 ms 66412 KB Output is correct
77 Correct 563 ms 66444 KB Output is correct
78 Correct 563 ms 66508 KB Output is correct
79 Correct 545 ms 66444 KB Output is correct
80 Correct 551 ms 66444 KB Output is correct
81 Correct 580 ms 66436 KB Output is correct
82 Correct 542 ms 66412 KB Output is correct
83 Correct 560 ms 66444 KB Output is correct
84 Correct 554 ms 66464 KB Output is correct
85 Correct 540 ms 66448 KB Output is correct
86 Correct 561 ms 66436 KB Output is correct
87 Correct 580 ms 66468 KB Output is correct
88 Correct 543 ms 66492 KB Output is correct
89 Correct 581 ms 66384 KB Output is correct
90 Correct 589 ms 66412 KB Output is correct
91 Correct 719 ms 66440 KB Output is correct
92 Correct 570 ms 66476 KB Output is correct
93 Correct 580 ms 66468 KB Output is correct
94 Correct 624 ms 66436 KB Output is correct
95 Correct 586 ms 66492 KB Output is correct
96 Correct 560 ms 66444 KB Output is correct
97 Correct 583 ms 66352 KB Output is correct
98 Correct 572 ms 66476 KB Output is correct
99 Correct 568 ms 66568 KB Output is correct
100 Correct 402 ms 66492 KB Output is correct
101 Correct 397 ms 66444 KB Output is correct
102 Correct 391 ms 66408 KB Output is correct
103 Correct 384 ms 66480 KB Output is correct
104 Correct 426 ms 66396 KB Output is correct
105 Correct 428 ms 66372 KB Output is correct
106 Correct 441 ms 66420 KB Output is correct
107 Correct 444 ms 66460 KB Output is correct
108 Correct 454 ms 66384 KB Output is correct
109 Correct 439 ms 66472 KB Output is correct
110 Correct 521 ms 66416 KB Output is correct
111 Correct 534 ms 66404 KB Output is correct
112 Correct 538 ms 66368 KB Output is correct
113 Correct 511 ms 66388 KB Output is correct
114 Correct 531 ms 66436 KB Output is correct
115 Correct 530 ms 66440 KB Output is correct
116 Correct 526 ms 66408 KB Output is correct
117 Correct 535 ms 66408 KB Output is correct
118 Correct 508 ms 66444 KB Output is correct
119 Correct 517 ms 66484 KB Output is correct
120 Correct 1 ms 468 KB Output is correct
121 Correct 1 ms 468 KB Output is correct
122 Correct 575 ms 66440 KB Output is correct
123 Correct 557 ms 66400 KB Output is correct
124 Correct 572 ms 66404 KB Output is correct
125 Correct 604 ms 66444 KB Output is correct
126 Correct 574 ms 66404 KB Output is correct
127 Correct 564 ms 66428 KB Output is correct
128 Correct 595 ms 66412 KB Output is correct
129 Correct 582 ms 66464 KB Output is correct
130 Correct 564 ms 66416 KB Output is correct
131 Correct 589 ms 66456 KB Output is correct
132 Correct 592 ms 66416 KB Output is correct
133 Correct 575 ms 66412 KB Output is correct