Submission #209277

#TimeUsernameProblemLanguageResultExecution timeMemory
209277kostia244Coin Collecting (JOI19_ho_t4)C++17
0 / 100
9 ms8184 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...