Submission #852944

#TimeUsernameProblemLanguageResultExecution timeMemory
852944hngwlogWiring (IOI17_wiring)C++14
13 / 100
23 ms3932 KiB
#include <bits/stdc++.h> #include "wiring.h" using namespace std; #define fi first #define se second #define _size(x) (int)x.size() #define BIT(i, x) ((x >> i) & 1) #define MASK(n) ((1 << n) - 1) #define REP(i, n) for (int i = 0, _n = (n); i < _n; i++) #define FOR(i, a, b) for (int i = a, _b = (b); i <= _b; i++) #define FORD(i, a, b) for (int i = a, _b = (b); i >= _b; i--) #define FORB1(i, mask) for (int i = mask; i > 0; i ^= i & - i) #define FORB0(i, n, mask) for (int i = ((1 << n) - 1) ^ mask; i > 0; i ^= i & - i) #define FORALL(i, a) for (auto i: a) #define fastio ios_base::sync_with_stdio(0); cin.tie(0); long long min_total_length(vector<int> r, vector<int> b) { long long ans = 0; int j = 0; REP(i, _size(r) - 1) { int left = _size(r) - 1 - i, cnt = 0; while (j <= _size(b) - 1 - left && abs(r[i] - b[j]) <= abs(r[i + 1] - b[j])) ans += abs(r[i] - b[j++]), cnt++; if (j > _size(b) - 1 - left && abs(r[i] - b[j])) ans += abs(r[i] - b[j]); else if (!cnt) ans += abs(r[i] - b[j++]); } FOR(i, j, _size(b) - 1) ans += abs(r.back() - b[i]); return ans; }
#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...