Submission #922152

#TimeUsernameProblemLanguageResultExecution timeMemory
922152asdasdqwerPalembang Bridges (APIO15_bridge)C++14
22 / 100
86 ms7616 KiB
#include <bits/stdc++.h> using namespace std; #define int int64_t #define pii array<int,2> signed main() { int k, n;cin>>k>>n; vector<pii> dif; int dis = 0; for (int i=0;i<n;i++) { char c1,c2; int p1,p2; cin>>c1>>p1>>c2>>p2; if (c1 == c2) { dis += abs(p1-p2); } else { dif.push_back({p1,p2}); } } if (k == 1) { if (dif.size() == 0) { cout<<dis<<"\n"; return 0; } vector<int> al; for (auto x:dif) { al.push_back(x[0]); al.push_back(x[1]); } sort(al.begin(),al.end()); int med = al[al.size() / 2]; for (int x:al) { dis += abs(x - med); } dis += dif.size(); cout<<dis<<"\n"; return 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...