# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
472277 |
2021-09-13T10:59:43 Z |
Ahmed57 |
Cipele (COCI18_cipele) |
C++14 |
|
96 ms |
980 KB |
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n,m;
cin>>n>>m;
vector<int>arr(n),aee(m);
for(int i =0;i<n;i++){
cin>>arr[i];
}
for(int i = 0;i<m;i++){
cin>>aee[i];
}
sort(arr.begin(),arr.end());sort(aee.begin(),aee.end());
if(m>n){swap(arr,aee);swap(n,m);}
if(n==m){
int sum = 0;
for(int i = 0;i<n;i++){
sum+=abs(arr[i]-aee[i]);
}
cout<<sum<<"\n";
}else if(n>m){
int ans = 0;
int y = 0;
for(int i = 0;i<m;i++){
for(;y<(n-m)+i;y++){
if(y<(((n-m)+i)-1)&&abs(arr[y]-aee[i])<=abs(arr[y+1]-aee[i]))break;
}
ans+=abs(arr[y]-aee[i]);
}
cout<<ans<<"\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
79 ms |
972 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
96 ms |
972 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
332 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
85 ms |
936 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
87 ms |
980 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
78 ms |
844 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |