제출 #420190

#제출 시각아이디문제언어결과실행 시간메모리
420190temurbek_khujaev전선 연결 (IOI17_wiring)C++17
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> #include "wiring.h" using namespace std; #define N 402 long long dp[N]; const long long INF = 1e18; long long min_total_length(std::vector<int> r, std::vector<int> b) { vector<pair<int, int >> v; for (auto x:r) v.push_back({x, -1}); for (auto x:b) v.push_back({x, 1}); v.push_back({-1, -2}); sort(v.begin(), v.end()); dp[0] = 0; for (int i = 1; i < v.size(); i++) { dp[i] = INF; int balance = 0; bool flag = true; for (int j = i; j > 0; j--) { balance += v[j].second; if (v[i].second != v[j].second && flag) { dp[i] = min(dp[i], dp[j - 1] + v[i].first - v[j].first); flag = false; } if (balance == 0) { long long cost = 0; vector<int> st[3]; for (int k = j; k <= i; k++) { st[v[k].second + 1].push_back(v[k].first); if (!st[0].empty() && !st[2].empty()) { cost += abs(st[2].back() - st[0].back()); st[0].pop_back(); st[1].pop_back(); } } dp[i] = min(dp[i], dp[j - 1] + cost); } } // cerr << dp[i] << ' '; } return dp[v.size() - 1]; }

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

wiring.cpp: In function 'long long int min_total_length(std::vector<int>, std::vector<int>)':
wiring.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int i = 1; i < v.size(); 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...