Submission #1073441

#TimeUsernameProblemLanguageResultExecution timeMemory
1073441hasan2006Wiring (IOI17_wiring)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> #include "wiring.h" using namespace std; #define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define rall(s) s.rbegin(),s.rend() #define all(s) s.begin(),s.end() #define pb push_back #define se second #define fi first #define ll long long #define ld long double #define YES cout<<"YES\n" #define Yes cout<<"Yes\n" #define yes cout<<"yes\n" #define NO cout<<"NO\n" #define No cout<<"No\n" #define no cout<<"no\n" const int N = 5e5 + 9 , mod = 1e9 + 7; ll a[N] , b[N] , dp[N] , c[N] , d[N] ; ll min_total_length(vector<int> a, vector<int> b){ a.pb(2e9); b.pb(2e9); deque<int>d1 , d2; int s = 0 , f , l, r , i , j , x , y , n , m; f = a.size() + b.size(); l = r= 0; while(f--){ if(a[l] <= b[r]){ if(d2.size() > 0) s += a[l] - d2.back() , d2.pop_back(); else d1.pb(a[l]); l++; }else { if(d1.size() > 0) s += b[r] - d1.back() , d1.pop_back(); else d2.pb(a[r]); r++; } } l = 0; for(i = 0; i < d1.size(); i++){ while(a[l] <= d1[i]) l++; x = a[l] - d1[i]; if(l) x = min(x ,d1[i] - a[l]); s += x; } l = 0; for(i = 0; i < d2.size(); i++){ while(b[l] <= d2[i]) l++; x = b[l] - d2[i]; if(l) x = min(x ,d2[i] - b[l]); s += x; } return s; }

Compilation message (stderr)

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:48:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     for(i = 0; i < d1.size(); i++){
      |                ~~^~~~~~~~~~~
wiring.cpp:57:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for(i = 0; i < d2.size(); i++){
      |                ~~^~~~~~~~~~~
wiring.cpp:28:32: warning: unused variable 'j' [-Wunused-variable]
   28 |     int s = 0 , f , l, r , i , j , x , y , n , m;
      |                                ^
wiring.cpp:28:40: warning: unused variable 'y' [-Wunused-variable]
   28 |     int s = 0 , f , l, r , i , j , x , y , n , m;
      |                                        ^
wiring.cpp:28:44: warning: unused variable 'n' [-Wunused-variable]
   28 |     int s = 0 , f , l, r , i , j , x , y , n , m;
      |                                            ^
wiring.cpp:28:48: warning: unused variable 'm' [-Wunused-variable]
   28 |     int s = 0 , f , l, r , i , j , x , y , n , m;
      |                                                ^
#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...