#include <bits/stdc++.h>
using namespace std;
long long min_total_length(vector <int> r, vector <int> b){
int n = r.size(), m = b.size();
vector < pair <int, int> > point(n + m);
int cnt = 0;
for (int p : r) point.push_back({p, cnt}), ++ cnt;
for (int p : b) point.push_back({p, cnt}), ++ cnt;
sort(point.begin(), point.end());
long long ans = 0;
int num = 0;
for (int i = 0; i < cnt - 1; ++ i){
auto [p, id] = point[i];
if (id < n) ++ num;
else -- num;
auto [_next, nid] = point[i + 1];
ans += 1ll * abs(num) * (_next - p);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
3rd lines differ - on the 1st token, expected: '25859', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
3rd lines differ - on the 1st token, expected: '904', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
508 KB |
3rd lines differ - on the 1st token, expected: '316', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
3rd lines differ - on the 1st token, expected: '27', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
3rd lines differ - on the 1st token, expected: '25859', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |