제출 #733618

#제출 시각아이디문제언어결과실행 시간메모리
733618SanguineChameleonPalembang Bridges (APIO15_bridge)C++17
22 / 100
41 ms3548 KiB
#include <bits/stdc++.h> using namespace std; void just_do_it(); int main() { #ifdef KAMIRULEZ freopen("kamirulez.inp", "r", stdin); freopen("kamirulez.out", "w", stdout); #endif ios_base::sync_with_stdio(0); cin.tie(0); just_do_it(); return 0; } void just_do_it() { int K, N; cin >> K >> N; vector<int> A; long long add = 0; for (int i = 0; i < N; i++) { char P, Q; int S, T; cin >> P >> S >> Q >> T; if (P == Q) { add += abs(S - T); } else { add++; A.push_back(S); A.push_back(T); } } if (A.empty()) { cout << add; return; } sort(A.begin(), A.end()); int M = A.size(); if (K == 1) { long long mid = A[(M - 1) / 2]; long long res = add; for (int i = 0; i < M; i++) { res += abs(A[i] - mid); } cout << res; return; } }
#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...