# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100754 | shihan04 | Wiring (IOI17_wiring) | C++11 | 0 ms | 0 KiB |
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<iostream>
using namespace std;
int main()
{
int n,m,r[100000],b[100000],greater;
long long min=0;
cin>>n>>m;
for(int i=0;i<n;i++){
cin>>r[i];
}
for(int j=0;j<m;j++){
cin>>b[j];
}
if(n<m){
greater=m;
for(int k=n;k<greater;k++){
r[k]=r[n-1];
}
}
else if(m<n){
greater=n;
for(int l=m;l<greater;l++){
b[l]=b[m-1];
}
}
for(int o=0;o<greater;o++){
if(r[o]>b[o])
min+=(r[o]-b[o]);
else if(b[o]>r[o])
min+=(b[o]-r[o]);
}
cout<<min;
return 0;
}