제출 #420870

#제출 시각아이디문제언어결과실행 시간메모리
420870temurbek_khujaev전선 연결 (IOI17_wiring)C++17
10 / 100
856 ms7144 KiB
#include "wiring.h" #include "bits/stdc++.h" using namespace std; const int N = 200100; 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, 0}); for (auto x:b) v.push_back({x, 1}); v.push_back({-2, -3});//0 sort(v.begin(), v.end()); dp[0] = 0; auto cost = [&](int l, int r) { vector<int> st[2]; long long res = 0; for (; l <= r; l++) st[v[l].second].push_back(v[l].first); if (st[0].empty() || st[1].empty()) return INF; for (int i = 0; i < min(st[0].size(), st[1].size()); i++) { res += abs(st[0][i] - st[1][i]); } if (st[0].size() < st[1].size()) { for (int i = st[0].size(); i < st[1].size(); i++) { res += min(abs(st[0].back() - st[1][i]), abs(st[0].front() - st[1][i])); } } else { for (int i = st[1].size(); i < st[0].size(); i++) { res += min(abs(st[1].back() - st[0][i]), abs(st[1].front() - st[0][i])); } }; return res; }; // cerr << cost(1, 3) << endl; for (int i = 1; i < (int) v.size(); i++) { dp[i] = INF; for (int j = max(1, i - 14); j < i; j++) { dp[i] = min(dp[i], dp[j - 1] + cost(j, i)); } // cerr << dp[i] << ' '; } return dp[v.size() - 1]; }

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

wiring.cpp: In lambda function:
wiring.cpp:23:27: warning: comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]
   23 |         for (int i = 0; i < min(st[0].size(), st[1].size()); i++) {
      |                         ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
wiring.cpp:28:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |             for (int i = st[0].size(); i < st[1].size(); i++) {
      |                                        ~~^~~~~~~~~~~~~~
wiring.cpp:32:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |             for (int i = st[1].size(); i < st[0].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...