답안 #532071

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
532071 2022-03-02T05:11:37 Z rk42745417 Coin Collecting (JOI19_ho_t4) C++17
37 / 100
112 ms 274436 KB
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(0);
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using ld = long double;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const ll LINF = ll(4e15) + ll(2e15);
const double EPS = 1e-9;
static int LamyIsCute = []() {
	EmiliaMyWife
	return 48763;
}();

signed main() {
	int n;
	cin >> n;
	vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, LINF));
	vector<pair<ll, ll>> arr(n * 2);
	for(int i = 0; i < n * 2; i++)
		cin >> arr[i].first >> arr[i].second;
	sort(arr.begin(), arr.end());
	dp[0][0] = 0;
	for(int i = 0; i <= n; i++) {
		for(int j = 0; j <= n; j++) {
			int x = i + j;
			if(i < n)
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + abs(arr[x].first - (i + 1)) + abs(arr[x].second - 2));
			if(j < n)
				dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + abs(arr[x].first - (j + 1)) + abs(arr[x].second - 1));
		}
	}
	cout << dp[n][n] << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 312 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 312 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 312 KB Output is correct
29 Correct 0 ms 304 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 308 KB Output is correct
32 Correct 0 ms 316 KB Output is correct
33 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 312 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 312 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 312 KB Output is correct
29 Correct 0 ms 304 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 308 KB Output is correct
32 Correct 0 ms 316 KB Output is correct
33 Correct 0 ms 204 KB Output is correct
34 Correct 10 ms 8140 KB Output is correct
35 Correct 11 ms 8188 KB Output is correct
36 Correct 11 ms 8140 KB Output is correct
37 Correct 12 ms 8256 KB Output is correct
38 Correct 11 ms 8136 KB Output is correct
39 Correct 10 ms 8140 KB Output is correct
40 Correct 13 ms 8140 KB Output is correct
41 Correct 13 ms 8256 KB Output is correct
42 Correct 13 ms 8240 KB Output is correct
43 Correct 12 ms 8140 KB Output is correct
44 Correct 12 ms 8136 KB Output is correct
45 Correct 10 ms 8140 KB Output is correct
46 Correct 11 ms 8140 KB Output is correct
47 Correct 10 ms 8140 KB Output is correct
48 Correct 12 ms 8140 KB Output is correct
49 Correct 12 ms 8252 KB Output is correct
50 Correct 11 ms 8136 KB Output is correct
51 Correct 10 ms 8140 KB Output is correct
52 Correct 12 ms 8132 KB Output is correct
53 Correct 11 ms 8140 KB Output is correct
54 Correct 12 ms 8140 KB Output is correct
55 Correct 14 ms 8204 KB Output is correct
56 Correct 12 ms 8136 KB Output is correct
57 Correct 11 ms 8132 KB Output is correct
58 Correct 10 ms 8132 KB Output is correct
59 Correct 11 ms 8260 KB Output is correct
60 Correct 10 ms 8140 KB Output is correct
61 Correct 10 ms 8140 KB Output is correct
62 Correct 11 ms 8140 KB Output is correct
63 Correct 12 ms 8140 KB Output is correct
64 Correct 10 ms 8140 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 312 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 312 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 312 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 312 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 0 ms 204 KB Output is correct
28 Correct 0 ms 312 KB Output is correct
29 Correct 0 ms 304 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 308 KB Output is correct
32 Correct 0 ms 316 KB Output is correct
33 Correct 0 ms 204 KB Output is correct
34 Correct 10 ms 8140 KB Output is correct
35 Correct 11 ms 8188 KB Output is correct
36 Correct 11 ms 8140 KB Output is correct
37 Correct 12 ms 8256 KB Output is correct
38 Correct 11 ms 8136 KB Output is correct
39 Correct 10 ms 8140 KB Output is correct
40 Correct 13 ms 8140 KB Output is correct
41 Correct 13 ms 8256 KB Output is correct
42 Correct 13 ms 8240 KB Output is correct
43 Correct 12 ms 8140 KB Output is correct
44 Correct 12 ms 8136 KB Output is correct
45 Correct 10 ms 8140 KB Output is correct
46 Correct 11 ms 8140 KB Output is correct
47 Correct 10 ms 8140 KB Output is correct
48 Correct 12 ms 8140 KB Output is correct
49 Correct 12 ms 8252 KB Output is correct
50 Correct 11 ms 8136 KB Output is correct
51 Correct 10 ms 8140 KB Output is correct
52 Correct 12 ms 8132 KB Output is correct
53 Correct 11 ms 8140 KB Output is correct
54 Correct 12 ms 8140 KB Output is correct
55 Correct 14 ms 8204 KB Output is correct
56 Correct 12 ms 8136 KB Output is correct
57 Correct 11 ms 8132 KB Output is correct
58 Correct 10 ms 8132 KB Output is correct
59 Correct 11 ms 8260 KB Output is correct
60 Correct 10 ms 8140 KB Output is correct
61 Correct 10 ms 8140 KB Output is correct
62 Correct 11 ms 8140 KB Output is correct
63 Correct 12 ms 8140 KB Output is correct
64 Correct 10 ms 8140 KB Output is correct
65 Runtime error 112 ms 274436 KB Execution killed with signal 9
66 Halted 0 ms 0 KB -