Submission #209279

# Submission time Handle Problem Language Result Execution time Memory
209279 2020-03-13T14:49:08 Z kostia244 Coin Collecting (JOI19_ho_t4) C++17
37 / 100
606 ms 23216 KB
#pragma GCC optimize("O2")
#pragma GCC target("avx,avx2,sse,sse2,ssse3,fma,tune=native")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 1e3 + 5;
ll n, dp[maxn][maxn];
map<int, vi> t;
vector<pi> a;

ll dist(pi a, pi b) {
	return abs(a.first - b.first) + abs(a.second - b.second);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	a.resize(2*n);
	for(int x, y, i = 0; i < 2*n; i++) cin >> a[i].first >> a[i].second;
	sort(all(a));
	memset(dp, 0x4f, sizeof dp);
	dp[0][0] = 0;
	for(int i = 0; i <= n; i++)
		for(int j = 0; j <= n && j+i < 2*n; j++) {
			if(dp[i][j] > 1e17) continue;
			int t = i+j;
			dp[i+1][j] = min(dp[i+1][j], dp[i][j] + dist({i+1, 1}, a[t]));
			dp[i][j+1] = min(dp[i][j+1], dp[i][j] + dist({j+1, 2}, a[t]));
		}
	cout << dp[n][n];
}

Compilation message

joi2019_ho_t4.cpp: In function 'int main()':
joi2019_ho_t4.cpp:24:10: warning: unused variable 'x' [-Wunused-variable]
  for(int x, y, i = 0; i < 2*n; i++) cin >> a[i].first >> a[i].second;
          ^
joi2019_ho_t4.cpp:24:13: warning: unused variable 'y' [-Wunused-variable]
  for(int x, y, i = 0; i < 2*n; i++) cin >> a[i].first >> a[i].second;
             ^
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8184 KB Output is correct
2 Correct 9 ms 8188 KB Output is correct
3 Correct 9 ms 8184 KB Output is correct
4 Correct 9 ms 8184 KB Output is correct
5 Correct 9 ms 8184 KB Output is correct
6 Correct 9 ms 8312 KB Output is correct
7 Correct 9 ms 8184 KB Output is correct
8 Correct 9 ms 8184 KB Output is correct
9 Correct 9 ms 8188 KB Output is correct
10 Correct 9 ms 8216 KB Output is correct
11 Correct 9 ms 8184 KB Output is correct
12 Correct 9 ms 8184 KB Output is correct
13 Correct 10 ms 8184 KB Output is correct
14 Correct 9 ms 8184 KB Output is correct
15 Correct 9 ms 8184 KB Output is correct
16 Correct 10 ms 8232 KB Output is correct
17 Correct 9 ms 8184 KB Output is correct
18 Correct 9 ms 8312 KB Output is correct
19 Correct 9 ms 8184 KB Output is correct
20 Correct 9 ms 8184 KB Output is correct
21 Correct 9 ms 8184 KB Output is correct
22 Correct 9 ms 8184 KB Output is correct
23 Correct 9 ms 8312 KB Output is correct
24 Correct 9 ms 8184 KB Output is correct
25 Correct 10 ms 8184 KB Output is correct
26 Correct 9 ms 8312 KB Output is correct
27 Correct 9 ms 8312 KB Output is correct
28 Correct 9 ms 8184 KB Output is correct
29 Correct 8 ms 8188 KB Output is correct
30 Correct 9 ms 8184 KB Output is correct
31 Correct 9 ms 8312 KB Output is correct
32 Correct 9 ms 8184 KB Output is correct
33 Correct 9 ms 8184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8184 KB Output is correct
2 Correct 9 ms 8188 KB Output is correct
3 Correct 9 ms 8184 KB Output is correct
4 Correct 9 ms 8184 KB Output is correct
5 Correct 9 ms 8184 KB Output is correct
6 Correct 9 ms 8312 KB Output is correct
7 Correct 9 ms 8184 KB Output is correct
8 Correct 9 ms 8184 KB Output is correct
9 Correct 9 ms 8188 KB Output is correct
10 Correct 9 ms 8216 KB Output is correct
11 Correct 9 ms 8184 KB Output is correct
12 Correct 9 ms 8184 KB Output is correct
13 Correct 10 ms 8184 KB Output is correct
14 Correct 9 ms 8184 KB Output is correct
15 Correct 9 ms 8184 KB Output is correct
16 Correct 10 ms 8232 KB Output is correct
17 Correct 9 ms 8184 KB Output is correct
18 Correct 9 ms 8312 KB Output is correct
19 Correct 9 ms 8184 KB Output is correct
20 Correct 9 ms 8184 KB Output is correct
21 Correct 9 ms 8184 KB Output is correct
22 Correct 9 ms 8184 KB Output is correct
23 Correct 9 ms 8312 KB Output is correct
24 Correct 9 ms 8184 KB Output is correct
25 Correct 10 ms 8184 KB Output is correct
26 Correct 9 ms 8312 KB Output is correct
27 Correct 9 ms 8312 KB Output is correct
28 Correct 9 ms 8184 KB Output is correct
29 Correct 8 ms 8188 KB Output is correct
30 Correct 9 ms 8184 KB Output is correct
31 Correct 9 ms 8312 KB Output is correct
32 Correct 9 ms 8184 KB Output is correct
33 Correct 9 ms 8184 KB Output is correct
34 Correct 15 ms 8312 KB Output is correct
35 Correct 15 ms 8312 KB Output is correct
36 Correct 15 ms 8312 KB Output is correct
37 Correct 16 ms 8312 KB Output is correct
38 Correct 15 ms 8312 KB Output is correct
39 Correct 15 ms 8312 KB Output is correct
40 Correct 16 ms 8312 KB Output is correct
41 Correct 16 ms 8312 KB Output is correct
42 Correct 15 ms 8312 KB Output is correct
43 Correct 15 ms 8312 KB Output is correct
44 Correct 15 ms 8312 KB Output is correct
45 Correct 15 ms 8312 KB Output is correct
46 Correct 17 ms 8316 KB Output is correct
47 Correct 15 ms 8312 KB Output is correct
48 Correct 16 ms 8316 KB Output is correct
49 Correct 15 ms 8312 KB Output is correct
50 Correct 15 ms 8312 KB Output is correct
51 Correct 15 ms 8312 KB Output is correct
52 Correct 16 ms 8312 KB Output is correct
53 Correct 16 ms 8312 KB Output is correct
54 Correct 15 ms 8312 KB Output is correct
55 Correct 15 ms 8312 KB Output is correct
56 Correct 15 ms 8312 KB Output is correct
57 Correct 15 ms 8312 KB Output is correct
58 Correct 16 ms 8312 KB Output is correct
59 Correct 16 ms 8312 KB Output is correct
60 Correct 15 ms 8312 KB Output is correct
61 Correct 15 ms 8312 KB Output is correct
62 Correct 18 ms 8224 KB Output is correct
63 Correct 15 ms 8312 KB Output is correct
64 Correct 15 ms 8312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 8184 KB Output is correct
2 Correct 9 ms 8188 KB Output is correct
3 Correct 9 ms 8184 KB Output is correct
4 Correct 9 ms 8184 KB Output is correct
5 Correct 9 ms 8184 KB Output is correct
6 Correct 9 ms 8312 KB Output is correct
7 Correct 9 ms 8184 KB Output is correct
8 Correct 9 ms 8184 KB Output is correct
9 Correct 9 ms 8188 KB Output is correct
10 Correct 9 ms 8216 KB Output is correct
11 Correct 9 ms 8184 KB Output is correct
12 Correct 9 ms 8184 KB Output is correct
13 Correct 10 ms 8184 KB Output is correct
14 Correct 9 ms 8184 KB Output is correct
15 Correct 9 ms 8184 KB Output is correct
16 Correct 10 ms 8232 KB Output is correct
17 Correct 9 ms 8184 KB Output is correct
18 Correct 9 ms 8312 KB Output is correct
19 Correct 9 ms 8184 KB Output is correct
20 Correct 9 ms 8184 KB Output is correct
21 Correct 9 ms 8184 KB Output is correct
22 Correct 9 ms 8184 KB Output is correct
23 Correct 9 ms 8312 KB Output is correct
24 Correct 9 ms 8184 KB Output is correct
25 Correct 10 ms 8184 KB Output is correct
26 Correct 9 ms 8312 KB Output is correct
27 Correct 9 ms 8312 KB Output is correct
28 Correct 9 ms 8184 KB Output is correct
29 Correct 8 ms 8188 KB Output is correct
30 Correct 9 ms 8184 KB Output is correct
31 Correct 9 ms 8312 KB Output is correct
32 Correct 9 ms 8184 KB Output is correct
33 Correct 9 ms 8184 KB Output is correct
34 Correct 15 ms 8312 KB Output is correct
35 Correct 15 ms 8312 KB Output is correct
36 Correct 15 ms 8312 KB Output is correct
37 Correct 16 ms 8312 KB Output is correct
38 Correct 15 ms 8312 KB Output is correct
39 Correct 15 ms 8312 KB Output is correct
40 Correct 16 ms 8312 KB Output is correct
41 Correct 16 ms 8312 KB Output is correct
42 Correct 15 ms 8312 KB Output is correct
43 Correct 15 ms 8312 KB Output is correct
44 Correct 15 ms 8312 KB Output is correct
45 Correct 15 ms 8312 KB Output is correct
46 Correct 17 ms 8316 KB Output is correct
47 Correct 15 ms 8312 KB Output is correct
48 Correct 16 ms 8316 KB Output is correct
49 Correct 15 ms 8312 KB Output is correct
50 Correct 15 ms 8312 KB Output is correct
51 Correct 15 ms 8312 KB Output is correct
52 Correct 16 ms 8312 KB Output is correct
53 Correct 16 ms 8312 KB Output is correct
54 Correct 15 ms 8312 KB Output is correct
55 Correct 15 ms 8312 KB Output is correct
56 Correct 15 ms 8312 KB Output is correct
57 Correct 15 ms 8312 KB Output is correct
58 Correct 16 ms 8312 KB Output is correct
59 Correct 16 ms 8312 KB Output is correct
60 Correct 15 ms 8312 KB Output is correct
61 Correct 15 ms 8312 KB Output is correct
62 Correct 18 ms 8224 KB Output is correct
63 Correct 15 ms 8312 KB Output is correct
64 Correct 15 ms 8312 KB Output is correct
65 Runtime error 606 ms 23216 KB Execution killed with signal 11 (could be triggered by violating memory limits)
66 Halted 0 ms 0 KB -