Submission #1060971

#TimeUsernameProblemLanguageResultExecution timeMemory
1060971vjudge1Wiring (IOI17_wiring)C++17
13 / 100
18 ms3264 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll min_total_length(vector<int> r, vector<int> b) { long long ans = 0; if(b.size() < r.size()) swap(r, b); for(int i = r.size() - 1; i > 0; i--) { ans += abs(b.back() - r[i]); b.pop_back(); while(b.size() > i && abs(b.back() - r[i - 1]) > abs(b.back() - r[i])) ans += abs(b.back() - r[i]), b.pop_back(); } for(int i : b) ans += abs(r[0] - i); return ans; } /* int main() { int n, m; cin >> n >> m; vector<int> a(n), b(m); for(int i = 0; i < n; i ++) cin >> a[i]; for(int i = 0; i < m ; i ++) cin >> b[i]; cout << min_total_length(a, b); return 0; } // */

Compilation message (stderr)

wiring.cpp: In function 'll min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:17:22: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   17 |       while(b.size() > i && abs(b.back() - r[i - 1]) > abs(b.back() - r[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...