Submission #1050641

#TimeUsernameProblemLanguageResultExecution timeMemory
1050641pawnedWiring (IOI17_wiring)C++17
13 / 100
25 ms6096 KiB
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")

#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;

#include "wiring.h"

ll min_total_length(vector<int> r_g, vector<int> b_g) {
	vi r, b;
	for (int x : r_g)
		r.pb(x);
	for (int x : b_g)
		b.pb(x);
	int N = r.size();
	int M = b.size();
	ll total = 0;
	if (N <= M) {	// more b than r
		for (int i = 0; i < N; i++) {
			total += (b[i] - r[i]);
		}
		for (int i = N; i < M; i++) {
			total += (b[i] - r[N - 1]);
		}
	}
	else {	// more r than b
		for (int i = 0; i < M; i++) {
			total += (b[i] - r[i]);
		}
		for (int i = M; i < N; i++) {
			total += (b[0] - r[i]);
		}
	}
	return total;
}
#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...