Submission #971845

#TimeUsernameProblemLanguageResultExecution timeMemory
971845Halym2007Palembang Bridges (APIO15_bridge)C++17
0 / 100
1 ms600 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define sz size() const int N = 1e5 + 5; ll n, k, goshmaly, x[N], y[N]; char s[N], d[N]; vector <ll> v; int main () { // freopen("input.txt", "r", stdin); cin >> k >> n; for (int i = 1; i <= n; ++i) { cin >> s[i] >> x[i] >> d[i] >> y[i]; if (s[i] == d[i]) { goshmaly += abs (x[i] - y[i]); } else { goshmaly++; v.pb (x[i] + y[i]); } } if (!v.empty()) { sort (v.begin(), v.end()); int n1 = (int)v.sz/2; ll med = v[n1]/2; for(int i = 1; i <= n; i++){ if(s[i] != d[i]){ goshmaly += abs(med - x[i]) + abs(med - y[i]); } } } cout << goshmaly; }
#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...