# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
788350 |
2023-07-20T06:58:59 Z |
NeroZein |
Wiring (IOI17_wiring) |
C++17 |
|
21 ms |
3788 KB |
#include "wiring.h"
#include "bits/stdc++.h"
using namespace std;
long long min_total_length(std::vector<int> r, std::vector<int> b) {
if (r.size() > b.size()) {
swap(r, b);
}
int n = (int) r.size();
int m = (int) b.size();
auto dis = [&](int i, int j) {
return abs(i - j);
};
sort(r.begin(), r.end());
sort(b.begin(), b.end());
int p = 0;
long long ans = 0;
for (int i = 0; i < n; ++i) {
bool f = false;
while (p < m && (i == n - 1 || dis(r[i], b[p]) < dis(r[i + 1], b[p])) && m - p - 1 >= n - i - 1) {
ans += dis(r[i], b[p]);
f = true;
p++;
}
if (!f) {
ans += dis(r[i], b[p]);
p++;
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '25859', found: '26187' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
15 ms |
2796 KB |
Output is correct |
4 |
Correct |
16 ms |
2932 KB |
Output is correct |
5 |
Correct |
18 ms |
2912 KB |
Output is correct |
6 |
Correct |
20 ms |
3748 KB |
Output is correct |
7 |
Correct |
21 ms |
3768 KB |
Output is correct |
8 |
Correct |
20 ms |
3788 KB |
Output is correct |
9 |
Correct |
19 ms |
3752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '17703', found: '19052' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
3rd lines differ - on the 1st token, expected: '27', found: '30' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
3rd lines differ - on the 1st token, expected: '25859', found: '26187' |
2 |
Halted |
0 ms |
0 KB |
- |