제출 #288795

#제출 시각아이디문제언어결과실행 시간메모리
288795Leonardo_Paes전선 연결 (IOI17_wiring)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include <wiring.h> 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; }

컴파일 시 표준 에러 (stderr) 메시지

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:9:19: 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=0; i<r.size(); i++) ans += abs(r[i] - b[i]);
      |                  ~^~~~~~~~~
wiring.cpp:10:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i=r.size(); i<b.size(); i++){
      |                         ~^~~~~~~~~
wiring.cpp:16:17: error: 'min' was not declared in this scope; did you mean 'std::min'?
   16 |             d = min(d, 1LL*abs(b[i] - *it));
      |                 ^~~
      |                 std::min
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from wiring.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: 'std::min' declared here
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~