Submission #840932

#TimeUsernameProblemLanguageResultExecution timeMemory
840932MathandskiPalembang Bridges (APIO15_bridge)C++17
0 / 100
1 ms464 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back #define is insert #define ll long long #define V vector #define MS multiset #define PL pair<ll, ll> #define F first #define S second #define PQ priority_queue #define f0r(i, begin, finish) for (ll i = begin; i < finish; i ++) #define For(i, finish, begin) for (ll i = finish; i > begin; i --) #define all(x) x.begin(), x.end() #define INF 1000000000000000000 #define inf 1000000000 #define MOD 998244353 #define len(x) (ll)x.size() #define fileread(file) ifstream fin; fin.open((string)file + ".in"); ofstream fout; fout.open((string)file + ".out") #define fastio ios_base::sync_with_stdio(0); cin.tie(nullptr) template<typename T> istream& operator>>(istream& in, V<T>& a) {for(auto &x : a) in >> x; return in;}; template<typename T> ostream& operator<<(ostream& out, V<T>& a) {for(auto &x : a) out << x << ' '; return out;}; int main () { int K, N; cin >> K >> N; ll tot = 0; if (K == 1) { V<ll> crits; V<PL> r; f0r (i, 0, N) { char a, b; ll x, y; cin >> a >> x >> b >> y; if (a == b) { tot += abs(x - y); } else { crits.pb(x); crits.pb(y); tot ++; r.pb({min(x, y), max(x, y)}); } } sort(all(crits)); ll opt = crits[len(crits) / 2]; for (auto ra : r) { tot += abs(ra.F - opt) + abs(ra.S - opt); } cout << tot << endl; } else { cout << 22 << endl; } }
#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...