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<bits/stdc++.h>
/*#include <cassert>
#include <cstdio>*/
#include "wiring.h"
using namespace std;
const long long MILLE=1000;
const long long INFINI=MILLE*MILLE*MILLE*MILLE*MILLE*MILLE,ZERO=0;
const int MAX_NB=100*1000;
int nbRouge,nbBleu,deb;
long long prix;
int rouge[MAX_NB],bleu[MAX_NB];
long long min_total_length(vector<int> r, vector<int> b) {
nbRouge=r.size();
nbBleu=b.size();
for (int i=0;i<nbRouge;i++) {
rouge[i]=r[i];
}
for (int i=0;i<nbBleu;i++) {
bleu[i]=b[i];
}
if (nbRouge>nbBleu) {
for (int i=0;nbRouge-i>nbBleu;i++) {
deb++;
prix+=(long long)b[0]-(long long)r[i];
}
for (int i=0;i<nbBleu;i++) {
prix+=(long long)b[i]-(long long)r[deb+i];
}
}
else {
for (int i=0;nbBleu-i>nbRouge;i++) {
deb++;
prix+=(long long)b[i]-(long long)r[nbRouge-1];
}
for (int i=0;i<nbRouge;i++) {
prix+=(long long)b[deb+i]-(long long)r[i];
}
}
return prix;
}
/*
int main() {
int n, m;
assert(2 == scanf("%d %d", &n, &m));
vector<int> r(n), b(m);
for(int i = 0; i < n; i++)
assert(1 == scanf("%d", &r[i]));
for(int i = 0; i < m; i++)
assert(1 == scanf("%d", &b[i]));
long long res = min_total_length(r, b);
printf("%lld\n", res);
return 0;
}
*/
# | 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... |