Submission #1005952

# Submission time Handle Problem Language Result Execution time Memory
1005952 2024-06-23T08:56:18 Z thangdz2k7 Wiring (IOI17_wiring) C++17
Compilation error
0 ms 0 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();
      |                           ^
/usr/bin/ld: /tmp/ccwkiIHV.o: in function `main':
grader.cpp:(.text.startup+0x23a): undefined reference to `min_total_length(std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status