답안 #122661

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
122661 2019-06-29T05:08:43 Z 윤교준(#3000) Bulldozer (JOI17_bulldozer) C++14
25 / 100
4 ms 504 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 < b;
}

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

	cin >> N;
	if(100 < N) exit(-1);
	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 372 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 504 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 380 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
3 Correct 3 ms 380 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 4 ms 504 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 4 ms 376 KB Output is correct
10 Correct 3 ms 504 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 380 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 4 ms 376 KB Output is correct
22 Correct 3 ms 504 KB Output is correct
23 Correct 4 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 3 ms 504 KB Output is correct
27 Correct 4 ms 504 KB Output is correct
28 Correct 4 ms 504 KB Output is correct
29 Correct 4 ms 376 KB Output is correct
30 Correct 3 ms 504 KB Output is correct
31 Correct 3 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 4 ms 504 KB Output is correct
3 Correct 3 ms 380 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 4 ms 504 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 4 ms 376 KB Output is correct
10 Correct 3 ms 504 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 380 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 4 ms 376 KB Output is correct
22 Correct 3 ms 504 KB Output is correct
23 Correct 4 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 3 ms 504 KB Output is correct
27 Correct 4 ms 504 KB Output is correct
28 Correct 4 ms 504 KB Output is correct
29 Correct 4 ms 376 KB Output is correct
30 Correct 3 ms 504 KB Output is correct
31 Correct 3 ms 504 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 504 KB Output is correct
2 Correct 4 ms 504 KB Output is correct
3 Correct 3 ms 380 KB Output is correct
4 Correct 4 ms 376 KB Output is correct
5 Correct 4 ms 504 KB Output is correct
6 Correct 4 ms 504 KB Output is correct
7 Correct 4 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 4 ms 376 KB Output is correct
10 Correct 3 ms 504 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 380 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 4 ms 376 KB Output is correct
22 Correct 3 ms 504 KB Output is correct
23 Correct 4 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 3 ms 504 KB Output is correct
27 Correct 4 ms 504 KB Output is correct
28 Correct 4 ms 504 KB Output is correct
29 Correct 4 ms 376 KB Output is correct
30 Correct 3 ms 504 KB Output is correct
31 Correct 3 ms 504 KB Output is correct
32 Correct 3 ms 376 KB Output is correct
33 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero
34 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 372 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 3 ms 504 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 504 KB Output is correct
8 Correct 3 ms 504 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 3 ms 504 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 380 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 4 ms 504 KB Output is correct
17 Correct 4 ms 504 KB Output is correct
18 Correct 3 ms 380 KB Output is correct
19 Correct 4 ms 376 KB Output is correct
20 Correct 4 ms 504 KB Output is correct
21 Correct 4 ms 504 KB Output is correct
22 Correct 4 ms 376 KB Output is correct
23 Correct 4 ms 376 KB Output is correct
24 Correct 4 ms 376 KB Output is correct
25 Correct 3 ms 504 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 380 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 376 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 376 KB Output is correct
37 Correct 3 ms 504 KB Output is correct
38 Correct 4 ms 376 KB Output is correct
39 Correct 3 ms 376 KB Output is correct
40 Correct 3 ms 376 KB Output is correct
41 Correct 3 ms 504 KB Output is correct
42 Correct 4 ms 504 KB Output is correct
43 Correct 4 ms 504 KB Output is correct
44 Correct 4 ms 376 KB Output is correct
45 Correct 3 ms 504 KB Output is correct
46 Correct 3 ms 504 KB Output is correct
47 Correct 3 ms 376 KB Output is correct
48 Runtime error 2 ms 376 KB Execution failed because the return code was nonzero
49 Halted 0 ms 0 KB -