Submission #288796

#TimeUsernameProblemLanguageResultExecution timeMemory
288796Leonardo_PaesWiring (IOI17_wiring)C++17
13 / 100
41 ms2060 KiB
#include <bits/stdc++.h> #include <wiring.h> using namespace std; const long long inf = 1e18+10; long long min_total_length(std::vector<int> r, std::vector<int> b) { long long ans = 0LL; if(r.size() > b.size()) swap(r, b); for(int i=0; i<r.size(); i++) ans += abs(r[i] - b[i]); for(int i=r.size(); i<b.size(); i++){ long long d = inf; auto it = lower_bound(r.begin(), r.end(), b[i]); if(it != r.end()) d = abs(b[i] - *it); if(it != r.begin()){ it--; d = min(d, 1LL*abs(b[i] - *it)); } if(d != inf) ans += d; } return ans; }

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:8:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for(int i=0; i<r.size(); i++) ans += abs(r[i] - b[i]);
      |                  ~^~~~~~~~~
wiring.cpp:9:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i=r.size(); i<b.size(); i++){
      |                         ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...