Submission #1036348

#TimeUsernameProblemLanguageResultExecution timeMemory
1036348beaconmcWiring (IOI17_wiring)C++14
0 / 100
759 ms139296 KiB
#include "wiring.h" #include <bits/stdc++.h> typedef long long ll; #define FOR(i,x,y) for(ll i=x; i<y; i++) #define FORNEG(i,x,y) for(ll i=x; i>y; i--) using namespace std; ll n,m; vector<ll> R,B; map<vector<ll>, ll> cache; ll dp(ll x, ll y){ if (abs(x-y) > 5) return 1000000000000000; if (cache.count({x,y})) return cache[{x,y}]; if (x==n && y==m) return 0; if (x>=n || y >= m) return 1000000000000000; return cache[{x,y}] = min(dp(x+1,y), min(dp(x,y+1), dp(x+1,y+1))) + abs(R[x] - B[y]); } long long min_total_length(std::vector<int> r, std::vector<int> b) { for (auto&i : r) R.push_back(i); for (auto&i : b) B.push_back(i); n = r.size(); m = b.size(); return dp(0,0); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...