이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "wiring.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define sz(x) (ll)x.size()
#define endl "\n"
#define pb push_back
#define F first
#define S second
typedef vector <ll> vi;
typedef pair <ll,ll> ii;
typedef vector <ii> vii;
#define dbg(x) cout<<#x<<": "<<x<<endl;
#define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl;
void printVct(vi &v){
for (ll i =0; i<sz(v); i++){
cout<<v[i]<<" ";
}
cout<<endl;
}
vi r, b;
long long min_total_length(vector<int> R, vector<int> B) {
ll n = sz(R), m = sz(B);
r.resize(n), b.resize(m);
for (ll i =0; i<n; i++){
r[i] = R[i];
}
for (ll i = 0; i<m; i++){
b[i] = B[i];
}
//subtask 2:
reverse(r.begin(), r.end());
ll ans = 0;
for (ll i =0; i<min(n,m); i++){
ans += abs(b[i] - r[i]);
}
if (n > m){
for (ll i =min(n,m); i<n; i++){
ans += abs(b[0]-r[i]);
}
}
else if (m > n){
for (ll i =min(n,m); i<m; i++){
ans += abs(b[i]-r[0]);
}
}
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... |