Submission #1069466

#TimeUsernameProblemLanguageResultExecution timeMemory
1069466giaminh2211Palembang Bridges (APIO15_bridge)C++14
22 / 100
30 ms3684 KiB
#include<bits/stdc++.h> using namespace std; using ll=long long; int k, n; const int N=1e5+13; int a[N]; ll res; char c1, c2; int x, y; vector<int> v; void scan(){ cin >> k >> n; for(int i=1; i<=n; i++){ cin >> c1 >> x >> c2 >> y; if(c1==c2){ res+=abs(x-y); } else{ v.push_back(x); v.push_back(y); ++res; } } sort(begin(v), end(v)); } void solve(){ for(int c: v){ res+=abs(c-v[v.size()/2-1]); } cout << res; } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); scan(); solve(); }
#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...