답안 #122660

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
122660 2019-06-29T05:04:44 Z 윤교준(#3000) Bulldozer (JOI17_bulldozer) C++14
75 / 100
1143 ms 16376 KB
#include <bits/stdc++.h>
#define upmax(a,b) (a)=max((a),(b))
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
pll operator + (const pll &a, const pll &b) { return pll(a.first+b.first, a.second+b.second); }
pll operator - (const pll &a, const pll &b) { return pll(a.first-b.first, a.second-b.second); }
ll operator * (const pll &a, const pll &b) { return a.first*b.second - b.first*a.second; }
ll ccw(const pll &a, const pll &b, const pll &c) { return a*b + b*c + c*a; }

const int MAXN = 2005;

struct SEG {
	ll ds[MAXN*4], dl[MAXN*4], dr[MAXN*4], dp[MAXN*4];

	void upd(int i, int s, int e, int x, int r) {
		if(s == e) {
			ds[i] = r;
			dl[i] = dr[i] = dp[i] = max(0, r);
			return;
		}
		int m = (s+e) >> 1;
		if(x <= m) upd(i<<1, s, m, x, r);
		else upd(i<<1|1, m+1, e, x, r);
		ds[i] = ds[i<<1] + ds[i<<1|1];
		dl[i] = max(dl[i<<1], ds[i<<1] + dl[i<<1|1]);
		dr[i] = max(dr[i<<1|1], ds[i<<1|1] + dr[i<<1]);
		dp[i] = max({dp[i<<1], dp[i<<1|1], dr[i<<1] + dl[i<<1|1]});
	}
	ll get() { return dp[1]; }
} seg;

pii EV[MAXN*MAXN/2];
pair<pll, int> P[MAXN];
int A[MAXN], B[MAXN];

ll Ans;
int N, EVn;

ll cmpccw(const pii &a, const pii &b) {
	return ccw(P[a.first].first, P[a.second].first
		, P[b.second].first - P[b.first].first + P[a.first].first);
}
bool cmp(const pii &a, const pii &b) {
	ll t = cmpccw(a, b);
	return t ? 0 < t : a.first < b.first;
}

int main() {
	ios::sync_with_stdio(false);

	cin >> N;
	for(int i = 1; i <= N; i++)
		cin >> P[i].first.first >> P[i].first.second >> P[i].second;
	sort(P+1, P+N+1);

	for(int i = 1; i < N; i++) for(int j = i+1; j <= N; j++)
		EV[++EVn] = pii(i, j);
	sort(EV+1, EV+EVn+1, cmp);

	iota(B, B+N+1, 0);
	for(int i = 1; i <= N; i++) seg.upd(1, 1, N, i, A[i] = P[i].second);

	Ans = seg.get();
	for(int s = 1, e; s <= EVn; s = e) {
		for(e = s+1; e <= EVn && !cmpccw(EV[s], EV[e]); e++);
		for(int i = s, a, b; i < e; i++) {
			tie(a, b) = EV[i];
			seg.upd(1, 1, N, B[a], A[b]);
			seg.upd(1, 1, N, B[b], A[a]);
			swap(B[a], B[b]);
		}
		upmax(Ans, seg.get());
	}

	cout << Ans << endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Incorrect 3 ms 376 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 4 ms 504 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 4 ms 376 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 376 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 3 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 4 ms 504 KB Output is correct
24 Correct 4 ms 504 KB Output is correct
25 Correct 4 ms 504 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 3 ms 504 KB Output is correct
28 Correct 3 ms 504 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 4 ms 504 KB Output is correct
31 Correct 4 ms 504 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 4 ms 504 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 4 ms 376 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 376 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 3 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 4 ms 504 KB Output is correct
24 Correct 4 ms 504 KB Output is correct
25 Correct 4 ms 504 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 3 ms 504 KB Output is correct
28 Correct 3 ms 504 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 4 ms 504 KB Output is correct
31 Correct 4 ms 504 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Correct 1128 ms 16208 KB Output is correct
34 Correct 1096 ms 16348 KB Output is correct
35 Correct 1120 ms 16348 KB Output is correct
36 Correct 1098 ms 16248 KB Output is correct
37 Correct 1101 ms 16248 KB Output is correct
38 Correct 1099 ms 16248 KB Output is correct
39 Correct 1100 ms 16248 KB Output is correct
40 Correct 1106 ms 16376 KB Output is correct
41 Correct 1104 ms 16120 KB Output is correct
42 Correct 1095 ms 16340 KB Output is correct
43 Correct 1114 ms 16248 KB Output is correct
44 Correct 1082 ms 16248 KB Output is correct
45 Correct 1088 ms 16248 KB Output is correct
46 Correct 1097 ms 16248 KB Output is correct
47 Correct 1084 ms 16248 KB Output is correct
48 Correct 1106 ms 16248 KB Output is correct
49 Correct 1105 ms 16248 KB Output is correct
50 Correct 1100 ms 16248 KB Output is correct
51 Correct 1096 ms 16336 KB Output is correct
52 Correct 1092 ms 16216 KB Output is correct
53 Correct 1097 ms 16376 KB Output is correct
54 Correct 1122 ms 16264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 4 ms 376 KB Output is correct
6 Correct 4 ms 376 KB Output is correct
7 Correct 4 ms 504 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 3 ms 504 KB Output is correct
10 Correct 4 ms 376 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 376 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 3 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 4 ms 504 KB Output is correct
24 Correct 4 ms 504 KB Output is correct
25 Correct 4 ms 504 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 3 ms 504 KB Output is correct
28 Correct 3 ms 504 KB Output is correct
29 Correct 3 ms 376 KB Output is correct
30 Correct 4 ms 504 KB Output is correct
31 Correct 4 ms 504 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Correct 1128 ms 16208 KB Output is correct
34 Correct 1096 ms 16348 KB Output is correct
35 Correct 1120 ms 16348 KB Output is correct
36 Correct 1098 ms 16248 KB Output is correct
37 Correct 1101 ms 16248 KB Output is correct
38 Correct 1099 ms 16248 KB Output is correct
39 Correct 1100 ms 16248 KB Output is correct
40 Correct 1106 ms 16376 KB Output is correct
41 Correct 1104 ms 16120 KB Output is correct
42 Correct 1095 ms 16340 KB Output is correct
43 Correct 1114 ms 16248 KB Output is correct
44 Correct 1082 ms 16248 KB Output is correct
45 Correct 1088 ms 16248 KB Output is correct
46 Correct 1097 ms 16248 KB Output is correct
47 Correct 1084 ms 16248 KB Output is correct
48 Correct 1106 ms 16248 KB Output is correct
49 Correct 1105 ms 16248 KB Output is correct
50 Correct 1100 ms 16248 KB Output is correct
51 Correct 1096 ms 16336 KB Output is correct
52 Correct 1092 ms 16216 KB Output is correct
53 Correct 1097 ms 16376 KB Output is correct
54 Correct 1122 ms 16264 KB Output is correct
55 Correct 1104 ms 16252 KB Output is correct
56 Correct 1101 ms 16244 KB Output is correct
57 Correct 1134 ms 16248 KB Output is correct
58 Correct 1109 ms 16212 KB Output is correct
59 Correct 1140 ms 16248 KB Output is correct
60 Correct 1112 ms 16340 KB Output is correct
61 Correct 1103 ms 16336 KB Output is correct
62 Correct 1118 ms 16276 KB Output is correct
63 Correct 1115 ms 16212 KB Output is correct
64 Correct 1119 ms 16344 KB Output is correct
65 Correct 1119 ms 16248 KB Output is correct
66 Correct 1107 ms 16348 KB Output is correct
67 Correct 1090 ms 16244 KB Output is correct
68 Correct 1109 ms 16248 KB Output is correct
69 Correct 1099 ms 16248 KB Output is correct
70 Correct 1143 ms 16340 KB Output is correct
71 Correct 1098 ms 16248 KB Output is correct
72 Correct 1116 ms 16376 KB Output is correct
73 Correct 1131 ms 16248 KB Output is correct
74 Correct 1113 ms 16244 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Incorrect 3 ms 376 KB Output isn't correct
7 Halted 0 ms 0 KB -