제출 #509752

#제출 시각아이디문제언어결과실행 시간메모리
509752sam571128Palembang Bridges (APIO15_bridge)C++17
22 / 100
42 ms5964 KiB
#include <bits/stdc++.h> #include <bits/extc++.h> #define int long long #define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); using namespace std; using namespace __gnu_pbds; typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; int t; signed main(){ fastio int k, n; cin >> k >> n; vector<int> tmp; int ans = 0; vector<pair<int,int>> v; for(int i = 0;i < n;i++){ char a,b; int x,y; cin >> a >> x >> b >> y; if(a == b) ans += abs(x-y); else{ ans++; v.push_back({x,y}); tmp.push_back(x); tmp.push_back(y); } } if(!tmp.empty()){ sort(tmp.begin(),tmp.end()); int med = tmp[tmp.size()/2]; for(auto [x,y] : v){ ans += abs(x-med)+abs(y-med); } } cout << ans << "\n"; }
#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...