Submission #298950

#TimeUsernameProblemLanguageResultExecution timeMemory
298950infinite_iqWiring (IOI17_wiring)C++14
0 / 100
1087 ms2936 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 ; ll N = ( !k ? b .size () : b .size () - k + 1 ) ; for ( int i = 0 ; i < N ; 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 ; }

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(vi, vi)':
wiring.cpp:17:33: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |                         if ( it != a .size () ) {
      |                              ~~~^~~~~~~~~~~~~
wiring.cpp:27:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |                 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...