Submission #972104

#TimeUsernameProblemLanguageResultExecution timeMemory
972104Halym2007Palembang Bridges (APIO15_bridge)C++17
22 / 100
40 ms6220 KiB
#include "bits/stdc++.h" #define ll long long int #define pb push_back #define pii pair<int,int> #define ff first #define ss second #define sz size() const int N = 2e5 + 1; using namespace std; ll n, k, x[N], y[N], gos; char s[N], d[N]; vector <int> v; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); //freopen("input.in", "r", stdin); //freopen("output.out", "w", stdout); cin >> k >> n; for(int i = 1; i <= n; i++){ cin >> s[i] >> x[i] >> d[i] >> y[i]; if(s[i] != d[i]){ gos++; v.pb(x[i]); v.pb(y[i]); } else { gos += abs (x[i] - y[i]); } } sort(v.begin(), v.end()); int n1 = v.sz/2; int med = v[n1]; for(auto i: v){ gos += abs(med-i); } cout << gos; }
#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...