답안 #51789

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
51789 2018-06-21T07:58:42 Z ainta Bulldozer (JOI17_bulldozer) C++17
55 / 100
569 ms 31864 KB
#include<cstdio>
#include<algorithm>
#define SZ 2048
using namespace std;
struct point2 {
	int x, y, i, j;
	bool operator<(const point2 &p)const {
		return (long long)y*p.x  < (long long)p.y*x;
	}
}P[2010000];
struct point {
	int x, y, c;
	bool operator<(const point &p)const {
		return x != p.x ? x < p.x : y > p.y;
	}
}w[2010];
long long res;
int n,cnt, Loc[2010];
struct Tree {
	long long L[SZ + SZ], R[SZ + SZ], S[SZ + SZ], M[SZ + SZ];
	void Put(int a, int b) {
		a += SZ;
		S[a] = b;
		L[a] = R[a] = M[a] = max(0, b);
		while (a != 1) {
			a >>= 1;
			S[a] = S[a + a] + S[a + a + 1];
			L[a] = max(L[a + a], S[a + a] + L[a + a + 1]);
			R[a] = max(R[a + a + 1], S[a + a + 1] + R[a + a]);
			M[a] = max(max(M[a + a], M[a + a + 1]), R[a + a] + L[a + a + 1]);
		}
	}
}T;
int main() {
	int i, j;
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d%d%d", &w[i].x, &w[i].y, &w[i].c);
	}
	sort(w + 1, w + n + 1);
	for (i = 1; i < n; i++) {
		for (j = i + 1; j <= n; j++) {
			int dx = w[j].x - w[i].x, dy = w[j].y - w[i].y;
			if (dx < 0 || (dx == 0 && dy < 0))dx = -dx, dy = -dy;
			P[cnt++] = { dx,dy,i,j };
		}
	}
	for (i = 1; i <= n; i++) {
		Loc[i] = i;
		T.Put(i, w[i].c);
	}
	sort(P, P + cnt);
	res = T.M[1];
	for (i = 0; i < cnt; i++) {
		for (j = i; j < cnt; j++) {
			if ((long long)P[i].x*P[j].y != (long long)P[i].y*P[j].x)break;
			int a = P[j].i, b = P[j].j;
			swap(Loc[a], Loc[b]);
			T.Put(Loc[a], w[a].c);
			T.Put(Loc[b], w[b].c);
		}
		res = max(res, T.M[1]);
		i = j - 1;
	}
	printf("%lld\n", res);
}

Compilation message

bulldozer.cpp: In function 'int main()':
bulldozer.cpp:36:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
  ~~~~~^~~~~~~~~~
bulldozer.cpp:38:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d%d", &w[i].x, &w[i].y, &w[i].c);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 472 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 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 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 3 ms 512 KB Output is correct
26 Correct 3 ms 512 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 3 ms 512 KB Output is correct
29 Correct 3 ms 504 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 4 ms 512 KB Output is correct
32 Correct 3 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 472 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 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 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 3 ms 512 KB Output is correct
26 Correct 3 ms 512 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 3 ms 512 KB Output is correct
29 Correct 3 ms 504 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 4 ms 512 KB Output is correct
32 Correct 3 ms 512 KB Output is correct
33 Correct 543 ms 31800 KB Output is correct
34 Correct 529 ms 31800 KB Output is correct
35 Correct 531 ms 31800 KB Output is correct
36 Correct 547 ms 31796 KB Output is correct
37 Correct 547 ms 31796 KB Output is correct
38 Correct 530 ms 31796 KB Output is correct
39 Correct 537 ms 31864 KB Output is correct
40 Correct 534 ms 31864 KB Output is correct
41 Correct 541 ms 31792 KB Output is correct
42 Correct 538 ms 31796 KB Output is correct
43 Correct 541 ms 31864 KB Output is correct
44 Correct 548 ms 31736 KB Output is correct
45 Correct 541 ms 31796 KB Output is correct
46 Correct 550 ms 31804 KB Output is correct
47 Correct 530 ms 31796 KB Output is correct
48 Correct 534 ms 31792 KB Output is correct
49 Correct 528 ms 31804 KB Output is correct
50 Correct 528 ms 31808 KB Output is correct
51 Correct 544 ms 31804 KB Output is correct
52 Correct 542 ms 31864 KB Output is correct
53 Correct 539 ms 31864 KB Output is correct
54 Correct 530 ms 31792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 3 ms 472 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 3 ms 384 KB Output is correct
8 Correct 3 ms 512 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 384 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 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 3 ms 384 KB Output is correct
22 Correct 3 ms 384 KB Output is correct
23 Correct 3 ms 384 KB Output is correct
24 Correct 3 ms 384 KB Output is correct
25 Correct 3 ms 512 KB Output is correct
26 Correct 3 ms 512 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 3 ms 512 KB Output is correct
29 Correct 3 ms 504 KB Output is correct
30 Correct 3 ms 384 KB Output is correct
31 Correct 4 ms 512 KB Output is correct
32 Correct 3 ms 512 KB Output is correct
33 Correct 543 ms 31800 KB Output is correct
34 Correct 529 ms 31800 KB Output is correct
35 Correct 531 ms 31800 KB Output is correct
36 Correct 547 ms 31796 KB Output is correct
37 Correct 547 ms 31796 KB Output is correct
38 Correct 530 ms 31796 KB Output is correct
39 Correct 537 ms 31864 KB Output is correct
40 Correct 534 ms 31864 KB Output is correct
41 Correct 541 ms 31792 KB Output is correct
42 Correct 538 ms 31796 KB Output is correct
43 Correct 541 ms 31864 KB Output is correct
44 Correct 548 ms 31736 KB Output is correct
45 Correct 541 ms 31796 KB Output is correct
46 Correct 550 ms 31804 KB Output is correct
47 Correct 530 ms 31796 KB Output is correct
48 Correct 534 ms 31792 KB Output is correct
49 Correct 528 ms 31804 KB Output is correct
50 Correct 528 ms 31808 KB Output is correct
51 Correct 544 ms 31804 KB Output is correct
52 Correct 542 ms 31864 KB Output is correct
53 Correct 539 ms 31864 KB Output is correct
54 Correct 530 ms 31792 KB Output is correct
55 Correct 528 ms 31800 KB Output is correct
56 Correct 569 ms 31796 KB Output is correct
57 Correct 557 ms 31796 KB Output is correct
58 Correct 562 ms 31804 KB Output is correct
59 Correct 525 ms 31864 KB Output is correct
60 Correct 539 ms 31796 KB Output is correct
61 Correct 549 ms 31800 KB Output is correct
62 Correct 550 ms 31804 KB Output is correct
63 Correct 533 ms 31792 KB Output is correct
64 Correct 522 ms 31780 KB Output is correct
65 Incorrect 529 ms 31792 KB Output isn't correct
66 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -