Submission #1005953

# Submission time Handle Problem Language Result Execution time Memory
1005953 2024-06-23T08:56:44 Z thangdz2k7 Wiring (IOI17_wiring) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>

using namespace std;

long long min_total_length(vector <int> r, vector <int> b){
    int n = r.size(); int m = b.size();

    vector < pair <int, int> > point;
    int cnt = 0;
    for (int p : r) point.push_back(pair <int, int> (p, cnt)), ++ cnt;
    for (int p : b) point.push_back(pair <int, int> (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;
}

Compilation message

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:6:27: warning: unused variable 'm' [-Wunused-variable]
    6 |     int n = r.size(); int m = b.size();
      |                           ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 3rd lines differ - on the 1st token, expected: '25859', found: '21413'
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: '904', found: '1109'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 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 0 ms 348 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 0 ms 348 KB 3rd lines differ - on the 1st token, expected: '25859', found: '21413'
2 Halted 0 ms 0 KB -