Submission #970657

#TimeUsernameProblemLanguageResultExecution timeMemory
970657kilkuwuPalembang Bridges (APIO15_bridge)C++17
22 / 100
32 ms3544 KiB
#include <bits/stdc++.h> #define nl '\n' signed main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int k, n; std::cin >> k >> n; int cnt = 0; std::vector<int> x_vals; int64_t ans = 0; for (int i = 0; i < n; i++) { char p, q; int s, t; std::cin >> p >> s >> q >> t; if (p == q) { ans += std::abs(t - s); } else { x_vals.push_back(s); x_vals.push_back(t); ans++; } } std::sort(x_vals.begin(), x_vals.end()); int med = x_vals.size() / 2; for (int i = 0; i < (int) x_vals.size(); i++) { ans += std::abs(x_vals[i] - x_vals[med]); } std::cout << ans << nl; } /* 1 5 B 0 A 4 B 1 B 3 A 5 B 7 B 2 A 6 B 1 A 7 */

Compilation message (stderr)

bridge.cpp: In function 'int main()':
bridge.cpp:11:7: warning: unused variable 'cnt' [-Wunused-variable]
   11 |   int cnt = 0;
      |       ^~~
#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...