Submission #971613

#TimeUsernameProblemLanguageResultExecution timeMemory
971613Halym2007Palembang Bridges (APIO15_bridge)C++17
8 / 100
2025 ms2896 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int N = 1e5 + 5; ll jogap, a[N], b[N]; int n, k; char oy[N], of[N]; ll hasapla (ll x) { ll ret = 0; for (int i = 1; i <= n; ++i) { if (oy[i] == of[i]) { ret += abs (a[i] - b[i]); } else { ret += abs (a[i] - x) + abs (x - b[i]) + 1; } } return ret; } int main () { // freopen ("input.txt", "r", stdin); cin >> k >> n; for (int i = 1; i <= n; ++i) { cin >> oy[i] >> a[i] >> of[i] >> b[i]; } // return cout << n << " " << k, 0; // for (int i = 1; i <= n; ++i) { // cout << i << " --> " << oy[i] << " " << a[i] << " " << of[i] << " " << b[i] << "\n"; // } // return 0; jogap = 2e18; for (int i = 1; i <= n; ++i) { jogap = min ({jogap, hasapla(a[i]), hasapla (b[i])}); } cout << jogap; }
#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...