답안 #590603

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
590603 2022-07-06T07:22:34 Z 장태환(#8413) Bulldozer (JOI17_bulldozer) C++17
75 / 100
635 ms 66508 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
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 x, y;
	int sa, sb;
	bool operator<(vec b)
	{
		return x * b.y < y * b.x;
	}
	bool operator==(vec b)
	{
		return x * b.y == y * b.x;
	}
};
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;
int x[2010];
int y[2010];
int c[2010];
int cp[2010];
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:91:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<vec>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   91 |  for (i = 0; i < od.size(); i++)
      |              ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Incorrect 1 ms 980 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 852 KB Output is correct
2 Correct 2 ms 852 KB Output is correct
3 Correct 2 ms 852 KB Output is correct
4 Correct 2 ms 852 KB Output is correct
5 Correct 2 ms 852 KB Output is correct
6 Correct 2 ms 852 KB Output is correct
7 Correct 2 ms 980 KB Output is correct
8 Correct 2 ms 980 KB Output is correct
9 Correct 3 ms 852 KB Output is correct
10 Correct 2 ms 852 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 0 ms 468 KB Output is correct
13 Correct 1 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 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 0 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 1 ms 852 KB Output is correct
24 Correct 2 ms 852 KB Output is correct
25 Correct 2 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 2 ms 980 KB Output is correct
30 Correct 2 ms 852 KB Output is correct
31 Correct 2 ms 980 KB Output is correct
32 Correct 2 ms 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 852 KB Output is correct
2 Correct 2 ms 852 KB Output is correct
3 Correct 2 ms 852 KB Output is correct
4 Correct 2 ms 852 KB Output is correct
5 Correct 2 ms 852 KB Output is correct
6 Correct 2 ms 852 KB Output is correct
7 Correct 2 ms 980 KB Output is correct
8 Correct 2 ms 980 KB Output is correct
9 Correct 3 ms 852 KB Output is correct
10 Correct 2 ms 852 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 0 ms 468 KB Output is correct
13 Correct 1 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 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 0 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 1 ms 852 KB Output is correct
24 Correct 2 ms 852 KB Output is correct
25 Correct 2 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 2 ms 980 KB Output is correct
30 Correct 2 ms 852 KB Output is correct
31 Correct 2 ms 980 KB Output is correct
32 Correct 2 ms 852 KB Output is correct
33 Correct 582 ms 66444 KB Output is correct
34 Correct 635 ms 66444 KB Output is correct
35 Correct 611 ms 66356 KB Output is correct
36 Correct 578 ms 66412 KB Output is correct
37 Correct 596 ms 66472 KB Output is correct
38 Correct 611 ms 66380 KB Output is correct
39 Correct 587 ms 66432 KB Output is correct
40 Correct 582 ms 66404 KB Output is correct
41 Correct 534 ms 66432 KB Output is correct
42 Correct 587 ms 66424 KB Output is correct
43 Correct 531 ms 66484 KB Output is correct
44 Correct 541 ms 66412 KB Output is correct
45 Correct 547 ms 66444 KB Output is correct
46 Correct 553 ms 66412 KB Output is correct
47 Correct 540 ms 66488 KB Output is correct
48 Correct 561 ms 66412 KB Output is correct
49 Correct 560 ms 66400 KB Output is correct
50 Correct 529 ms 66412 KB Output is correct
51 Correct 597 ms 66428 KB Output is correct
52 Correct 518 ms 66444 KB Output is correct
53 Correct 558 ms 66500 KB Output is correct
54 Correct 525 ms 66412 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 852 KB Output is correct
2 Correct 2 ms 852 KB Output is correct
3 Correct 2 ms 852 KB Output is correct
4 Correct 2 ms 852 KB Output is correct
5 Correct 2 ms 852 KB Output is correct
6 Correct 2 ms 852 KB Output is correct
7 Correct 2 ms 980 KB Output is correct
8 Correct 2 ms 980 KB Output is correct
9 Correct 3 ms 852 KB Output is correct
10 Correct 2 ms 852 KB Output is correct
11 Correct 1 ms 468 KB Output is correct
12 Correct 0 ms 468 KB Output is correct
13 Correct 1 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 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 0 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 1 ms 852 KB Output is correct
24 Correct 2 ms 852 KB Output is correct
25 Correct 2 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 2 ms 980 KB Output is correct
30 Correct 2 ms 852 KB Output is correct
31 Correct 2 ms 980 KB Output is correct
32 Correct 2 ms 852 KB Output is correct
33 Correct 582 ms 66444 KB Output is correct
34 Correct 635 ms 66444 KB Output is correct
35 Correct 611 ms 66356 KB Output is correct
36 Correct 578 ms 66412 KB Output is correct
37 Correct 596 ms 66472 KB Output is correct
38 Correct 611 ms 66380 KB Output is correct
39 Correct 587 ms 66432 KB Output is correct
40 Correct 582 ms 66404 KB Output is correct
41 Correct 534 ms 66432 KB Output is correct
42 Correct 587 ms 66424 KB Output is correct
43 Correct 531 ms 66484 KB Output is correct
44 Correct 541 ms 66412 KB Output is correct
45 Correct 547 ms 66444 KB Output is correct
46 Correct 553 ms 66412 KB Output is correct
47 Correct 540 ms 66488 KB Output is correct
48 Correct 561 ms 66412 KB Output is correct
49 Correct 560 ms 66400 KB Output is correct
50 Correct 529 ms 66412 KB Output is correct
51 Correct 597 ms 66428 KB Output is correct
52 Correct 518 ms 66444 KB Output is correct
53 Correct 558 ms 66500 KB Output is correct
54 Correct 525 ms 66412 KB Output is correct
55 Correct 578 ms 66448 KB Output is correct
56 Correct 560 ms 66456 KB Output is correct
57 Correct 594 ms 66400 KB Output is correct
58 Correct 540 ms 66400 KB Output is correct
59 Correct 555 ms 66460 KB Output is correct
60 Correct 533 ms 66448 KB Output is correct
61 Correct 547 ms 66412 KB Output is correct
62 Correct 546 ms 66380 KB Output is correct
63 Correct 551 ms 66408 KB Output is correct
64 Correct 575 ms 66412 KB Output is correct
65 Correct 535 ms 66380 KB Output is correct
66 Correct 548 ms 66508 KB Output is correct
67 Correct 531 ms 66444 KB Output is correct
68 Correct 538 ms 66400 KB Output is correct
69 Correct 562 ms 66436 KB Output is correct
70 Correct 515 ms 66404 KB Output is correct
71 Correct 579 ms 66428 KB Output is correct
72 Correct 545 ms 66420 KB Output is correct
73 Correct 537 ms 66412 KB Output is correct
74 Correct 520 ms 66380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 980 KB Output is correct
2 Incorrect 1 ms 980 KB Output isn't correct
3 Halted 0 ms 0 KB -