이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll min_total_length(vector<int> r, vector<int> b)
{
long long ans = 0;
while(r.size() && b.size())
{
if(r.size() > b.size()) swap(r, b);
ans += abs(r.back() - b.back());
if(r.size() == b.size())
r.pop_back();
else
{
if(r.size() > 1 && abs(b.back() - r[r.size() - 2]) <= abs(b.back() - r.back()))
r.pop_back();
}
b.pop_back();
}
return ans;
}
/*
int main()
{
int n, m;
cin >> n >> m;
vector<int> a(n), b(m);
for(int i = 0; i < n; i ++) cin >> a[i];
for(int i = 0; i < m ; i ++) cin >> b[i];
cout << min_total_length(a, b);
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... |