# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
165119 | Segtree | Wiring (IOI17_wiring) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
#include"wiring.h"
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 210
ll min_total_length(vector<int> a,vector<int> b){
ll ans=0;
for(int i=0;i<a.size();i++)ans+=b[0]-a[i];
for(int i=1;i<b.size();i++)ans+=b[i]-a[a.size()-1];
return ans;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
vector<int> a,b;
ll n,m; cin>>n>>m;
for(int i=0;i<n;i++){
int x; cin>>x;
a.push_back(x);
}
for(int i=0;i<m;i++){
int x; cin>>x;
b.push_back(x);
}
cout<<min_total_length(a,b)<<endl;
}