제출 #958202

#제출 시각아이디문제언어결과실행 시간메모리
958202riaritiPalembang Bridges (APIO15_bridge)C++17
22 / 100
27 ms7896 KiB
#line 1 "Palembang_Bridges.cpp" #include <bits/stdc++.h> #ifdef local #define dbg(__VA_ARGS__) \ std::cerr << "[DBG|" << __LINE__ << "]: " << __VA_ARGS__ << std::endl; #define cerr(__VA_ARGS__) std::cerr << __VA_ARGS__; #else #define dbg(...) #define cerr(...) #endif const auto vec_out = [](const std::vector<int> &cc) { dbg("vector: "); for (auto x : cc) { cerr(x << " "); } cerr("\n"); }; int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int K, N; std::cin >> K >> N; std::vector<std::tuple<char, std::int64_t, char, std::int64_t>> PSQT(N); for (auto &[P, S, Q, T] : PSQT) { std::cin >> P >> S >> Q >> T; } std::int64_t ans = 0; std::vector<std::pair<std::int64_t, std::int64_t>> HW; for (auto [P, S, Q, T] : PSQT) { if (P == Q) { ans += std::abs(T - S); continue; } HW.emplace_back(S, T); } auto f = [&](int x) { std::int64_t ans = 0; for (auto [S, T] : HW) { // +1 for bridge ans += std::abs(S - x) + std::abs(T - x) + 1; } return ans; }; std::int64_t l = 0, r = 1'000'000'001; while (l <= r) { auto m = l + (r - l) / 2; if (!(f(m) <= f(m + 1))) { l = m + 1; } else { r = m - 1; } } ans += f(l); std::cout << ans << "\n"; return 0; }

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

Palembang_Bridges.cpp: In lambda function:
Palembang_Bridges.cpp:14:15: warning: unused variable 'x' [-Wunused-variable]
#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...