제출 #958199

#제출 시각아이디문제언어결과실행 시간메모리
958199riaritiPalembang Bridges (APIO15_bridge)C++17
0 / 100
1 ms348 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, int, char, int>> PSQT(N); for (auto &[P, S, Q, T] : PSQT) { std::cin >> P >> S >> Q >> T; } std::vector<int> pos; for (auto [P, S, Q, T] : PSQT) { pos.push_back(S); pos.push_back(T); } std::sort(pos.begin(), pos.end()); std::int64_t ans = LLONG_MAX; for (auto m : {pos.size() / 2 + 1}) { std::int64_t res = 0; for (auto [P, S, Q, T] : PSQT) { res += static_cast<std::int64_t>(std::abs(S - pos[m])) + std::abs(T - pos[m]); } ans = std::min(ans, res); } 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...