# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
43226 | szawinis | Wiring (IOI17_wiring) | C++14 | 155 ms | 76372 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>
#define pos first
#define col second
using namespace std;
using ll = long long;
const int N = 2e5+1;
const ll INF = 1e17;
int n;
vector<pair<int,int> > a;
ll s[N], dp[N];
inline ll fl(int j, int k) { // j, k part of sum when i-k < k-j
return dp[j] + s[j] - 2*s[k] - 1ll * (j-2*k) * a[k+1].pos;
}
inline ll fg(int j, int k) {
return dp[j] + s[j] - 2*s[k] - 1ll * (j-2*k) * a[k].pos;
}
set<pair<ll,int> > stl, stg; // l: j <= 2*k-i, g: j > 2*k-i
ll min_total_length(std::vector<int> r, std::vector<int> b) {
n = r.size() + b.size();
for(int i = 0; i < r.size(); i++) a.emplace_back(r[i], 0);
for(int i = 0; i < b.size(); i++) a.emplace_back(b[i], 1);
a.emplace_back(INT_MIN, INT_MIN);
sort(a.begin(), a.end());
for(int i = 1; i <= n; i++) s[i] = s[i-1] + a[i].pos;
fill(dp+1, dp+n+1, INF);
for(int i = 2, k = 0; i <= n; i++) {
if(a[i].col != a[i-1].col) {
k = i-1;
Compilation message (stderr)
# | 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... |