# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
127709 | 2019-07-10T03:04:34 Z | arnold518 | Coin Collecting (JOI19_ho_t4) | C++14 | 20 ms | 8312 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1000; const ll INF = 1e17; struct Point { ll x, y; bool operator < (const Point& p) { return x<p.x; } }; ll dist(Point p, Point q) { return abs(p.x-q.x)+abs(p.y-q.y); } int N; Point coin[2*MAXN+10]; ll dp[MAXN+10][MAXN+10]; int main() { int i, j; scanf("%d", &N); for(i=1; i<=2*N; i++) scanf("%lld%lld", &coin[i].x, &coin[i].y); sort(coin+1, coin+2*N+1); for(i=0; i<=N; i++) for(j=0; j<=N; j++) { if(i==0 && j==0) continue; dp[i][j]=INF; if(i!=0) dp[i][j]=min(dp[i][j], dist(coin[i+j], {i, 1})+dp[i-1][j]); if(j!=0) dp[i][j]=min(dp[i][j], dist(coin[i+j], {j, 2})+dp[i][j-1]); } printf("%lld", dp[N][N]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 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 | 312 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 | 380 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Correct | 2 ms | 376 KB | Output is correct |
25 | Correct | 2 ms | 376 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 | 380 KB | Output is correct |
31 | Correct | 2 ms | 376 KB | Output is correct |
32 | Correct | 2 ms | 380 KB | Output is correct |
33 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 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 | 312 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 | 380 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Correct | 2 ms | 376 KB | Output is correct |
25 | Correct | 2 ms | 376 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 | 380 KB | Output is correct |
31 | Correct | 2 ms | 376 KB | Output is correct |
32 | Correct | 2 ms | 380 KB | Output is correct |
33 | Correct | 2 ms | 376 KB | Output is correct |
34 | Correct | 14 ms | 8244 KB | Output is correct |
35 | Correct | 14 ms | 8312 KB | Output is correct |
36 | Correct | 14 ms | 8312 KB | Output is correct |
37 | Correct | 14 ms | 8312 KB | Output is correct |
38 | Correct | 14 ms | 8184 KB | Output is correct |
39 | Correct | 14 ms | 8184 KB | Output is correct |
40 | Correct | 15 ms | 8184 KB | Output is correct |
41 | Correct | 20 ms | 8284 KB | Output is correct |
42 | Correct | 14 ms | 8184 KB | Output is correct |
43 | Correct | 16 ms | 8312 KB | Output is correct |
44 | Correct | 16 ms | 8312 KB | Output is correct |
45 | Correct | 14 ms | 8188 KB | Output is correct |
46 | Correct | 15 ms | 8184 KB | Output is correct |
47 | Correct | 14 ms | 8312 KB | Output is correct |
48 | Correct | 15 ms | 8184 KB | Output is correct |
49 | Correct | 14 ms | 8184 KB | Output is correct |
50 | Correct | 14 ms | 8184 KB | Output is correct |
51 | Correct | 14 ms | 8184 KB | Output is correct |
52 | Correct | 14 ms | 8312 KB | Output is correct |
53 | Correct | 14 ms | 8184 KB | Output is correct |
54 | Correct | 15 ms | 8312 KB | Output is correct |
55 | Correct | 15 ms | 8188 KB | Output is correct |
56 | Correct | 14 ms | 8184 KB | Output is correct |
57 | Correct | 15 ms | 8312 KB | Output is correct |
58 | Correct | 15 ms | 8312 KB | Output is correct |
59 | Correct | 15 ms | 8184 KB | Output is correct |
60 | Correct | 15 ms | 8184 KB | Output is correct |
61 | Correct | 14 ms | 8260 KB | Output is correct |
62 | Correct | 14 ms | 8312 KB | Output is correct |
63 | Correct | 14 ms | 8312 KB | Output is correct |
64 | Correct | 14 ms | 8312 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 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 | 312 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 | 380 KB | Output is correct |
20 | Correct | 2 ms | 376 KB | Output is correct |
21 | Correct | 2 ms | 376 KB | Output is correct |
22 | Correct | 2 ms | 376 KB | Output is correct |
23 | Correct | 2 ms | 376 KB | Output is correct |
24 | Correct | 2 ms | 376 KB | Output is correct |
25 | Correct | 2 ms | 376 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 | 380 KB | Output is correct |
31 | Correct | 2 ms | 376 KB | Output is correct |
32 | Correct | 2 ms | 380 KB | Output is correct |
33 | Correct | 2 ms | 376 KB | Output is correct |
34 | Correct | 14 ms | 8244 KB | Output is correct |
35 | Correct | 14 ms | 8312 KB | Output is correct |
36 | Correct | 14 ms | 8312 KB | Output is correct |
37 | Correct | 14 ms | 8312 KB | Output is correct |
38 | Correct | 14 ms | 8184 KB | Output is correct |
39 | Correct | 14 ms | 8184 KB | Output is correct |
40 | Correct | 15 ms | 8184 KB | Output is correct |
41 | Correct | 20 ms | 8284 KB | Output is correct |
42 | Correct | 14 ms | 8184 KB | Output is correct |
43 | Correct | 16 ms | 8312 KB | Output is correct |
44 | Correct | 16 ms | 8312 KB | Output is correct |
45 | Correct | 14 ms | 8188 KB | Output is correct |
46 | Correct | 15 ms | 8184 KB | Output is correct |
47 | Correct | 14 ms | 8312 KB | Output is correct |
48 | Correct | 15 ms | 8184 KB | Output is correct |
49 | Correct | 14 ms | 8184 KB | Output is correct |
50 | Correct | 14 ms | 8184 KB | Output is correct |
51 | Correct | 14 ms | 8184 KB | Output is correct |
52 | Correct | 14 ms | 8312 KB | Output is correct |
53 | Correct | 14 ms | 8184 KB | Output is correct |
54 | Correct | 15 ms | 8312 KB | Output is correct |
55 | Correct | 15 ms | 8188 KB | Output is correct |
56 | Correct | 14 ms | 8184 KB | Output is correct |
57 | Correct | 15 ms | 8312 KB | Output is correct |
58 | Correct | 15 ms | 8312 KB | Output is correct |
59 | Correct | 15 ms | 8184 KB | Output is correct |
60 | Correct | 15 ms | 8184 KB | Output is correct |
61 | Correct | 14 ms | 8260 KB | Output is correct |
62 | Correct | 14 ms | 8312 KB | Output is correct |
63 | Correct | 14 ms | 8312 KB | Output is correct |
64 | Correct | 14 ms | 8312 KB | Output is correct |
65 | Execution timed out | 3 ms | 376 KB | Time limit exceeded (wall clock) |
66 | Halted | 0 ms | 0 KB | - |