Submission #209277

# Submission time Handle Problem Language Result Execution time Memory
209277 2020-03-13T14:46:28 Z kostia244 Coin Collecting (JOI19_ho_t4) C++17
0 / 100
9 ms 8184 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+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({i+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 Incorrect 9 ms 8184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 8184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 8184 KB Output isn't correct
2 Halted 0 ms 0 KB -