Submission #425657

#TimeUsernameProblemLanguageResultExecution timeMemory
425657Tangent전선 연결 (IOI17_wiring)C++17
13 / 100
31 ms1848 KiB
#include "wiring.h"
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vii;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vii> vvii;
typedef vector<vll> vvll;
typedef vector<vpii> vvpii;
typedef vector<vpll> vvpll;

#define ffor(i, a, b) for (ll i = (a); i < (ll)(b); i++)
#define fford(i, a, b) for (ll i = (a); i > (ll)(b); i--)
#define rep(i, n) ffor(i, 0, n)
#define forin(x, a) for (auto &x: a)
#define all(a) a.begin(), a.end()

long long min_total_length(std::vector<int> r, std::vector<int> b) {
	if (r.size() >= b.size()) {
		ll res = 0;
		rep(i, b.size()) {
			res += abs(b[i] - r[r.size() - 1 - i]);
		}
		rep(i, r.size() - b.size()) {
			res += abs(r[i] - b[0]);
		}
		return res;
	}
	ll res = 0;
	rep(i, r.size()) {
		res += abs(b[i] - r[r.size() - 1 - i]);
	}
	rep(i, b.size() - r.size()) {
		res += abs(r.back() - b[b.size() - 1 - i]);
	}
	return res;
}
#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...