# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
261915 | kdh9949 | Wiring (IOI17_wiring) | C++17 | 77 ms | 12772 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "wiring.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct Pos { ll x; int t; };
ll min_total_length(vector<int> r, vector<int> b) {
vector<Pos> a;
a.push_back({-1LL, -1});
for(int x : r) a.push_back({x, 0});
for(int x : b) a.push_back({x, 1});
sort(a.begin(), a.end(), [](Pos &u, Pos &v){ return u.x < v.x; });
int n = int(a.size()) - 1;
const static ll INF = ll(1e18);
vector<ll> d(n + 1, 0), s(n + 1, 0);
for(int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i].x;
for(int i = 1; a[i].t == a[1].t; i++) d[i] = INF;
vector<ll> pm(n + 1), sm(n + 1);
for(int i = 1; i <= n - 1; i++) {
if(a[i].t == a[i + 1].t) continue;
int L, R;
for(L = i; L > 1 && a[L - 1].t == a[i].t; L--);
for(R = i + 1; R < n && a[R + 1].t == a[i + 1].t; R++);
ll md = d[i];
for(int j = i; j >= L; j--) {
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |