Submission #294909

#TimeUsernameProblemLanguageResultExecution timeMemory
294909Aldas25Wiring (IOI17_wiring)C++14
13 / 100
39 ms3832 KiB
#include "wiring.h"
#include <bits/stdc++.h>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;

long long min_total_length(std::vector<int> r, std::vector<int> b) {
	int n = (int)r.size();
	int m = (int)b.size();

    ll rMost = r[n-1], lMost = b[0];
    int fId = 0, sId = 0;
    ll ans = 0;
    while (fId < n && sId < m) {
        ans += b[sId] - r[fId];
        fId++, sId++;
    }
    while (sId < m) {
        ans += b[sId] - rMost;
        sId++;
    }
    while (fId < n) {
        ans += lMost - r[fId];
        fId++;
    }

	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...