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 std::cin;
using std::cout;
using std::vector;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using std::string;
using pii = std::pair<ll,ll>;
#define rep(i,j,k) for(ll i=ll(j); i<ll(k); i++)
#define REP(i,j,k) for(ll i=ll(j); i<=ll(k); i++)
#define per(i,j,k) for(ll i=ll(j); i>=ll(k); i--)
#define ln "\n"
#define all(a) a.begin(), a.end()
#define mp std::make_pair
#define pb emplace_back
constexpr ll inf = (1ll<<60);
long long min_total_length(std::vector<int> r, std::vector<int> b) {
vector<pii> data;
for(auto el: r) data.pb(mp(el,0));
for(auto el: b) data.pb(mp(el,1));
sort(all(data));
ll N = r.size(), M = b.size();
ll ans = 0;
rep(i,0,N) ans -= r[i];
rep(i,0,M) ans += b[i];
if(N < M) ans -= r.back()*(M-N);
else ans += b[0]*(N-M);
return ans;
}
# | 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... |