제출 #298937

#제출 시각아이디문제언어결과실행 시간메모리
298937infinite_iq전선 연결 (IOI17_wiring)C++14
0 / 100
1091 ms2680 KiB
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef vector < int > vi ;
#define lb lower_bound
#include "wiring.h"
long long min_total_length ( vi a , vi b ) {
        if ( a .size () > b .size () ) swap ( a , b ) ;
        int k = b .size () - a .size () ;
        ll ans = 1e18 ;
        for ( int i = 0 ; i + k - 1 < b .size () ; i ++ ) {
                ll cost = 0 ;
                for ( int j = i ; j < i + k ; j ++ ) {
                        ll ret = 1e8 ; 
                        auto it = lb ( a .begin () , a .end () , b [j] ) - a .begin () ;
                        if ( it != a .size () ) {
                                ret = min ( ret , (ll) ( abs ( a [it] - b [j] ) ) ) ;
                        }
                        it -- ;
                        if ( it != -1 ) {
                                ret = min ( ret , (ll) ( abs ( a [it] - b [j] ) ) ) ;
                        }
                        cost += ret ;
                }
                int it = 0 ;
                for ( int j = 0 ; j < b .size () ; j ++ ) {
                        if ( i <= j && j < i + k ) continue ;
                        cost += abs ( b [j] - a [it++] ) ;
                }
                ans = min ( ans , cost ) ;
        }
        return ans ;
}

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

wiring.cpp: In function 'long long int min_total_length(vi, vi)':
wiring.cpp:11:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |         for ( int i = 0 ; i + k - 1 < b .size () ; i ++ ) {
      |                           ~~~~~~~~~~^~~~~~~~~~~~
wiring.cpp:16:33: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |                         if ( it != a .size () ) {
      |                              ~~~^~~~~~~~~~~~~
wiring.cpp:26:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |                 for ( int j = 0 ; j < b .size () ; j ++ ) {
      |                                   ~~^~~~~~~~~~~~
#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...