제출 #380815

#제출 시각아이디문제언어결과실행 시간메모리
380815LittlePantsPalembang Bridges (APIO15_bridge)C++17
22 / 100
46 ms4208 KiB
#include<bits/stdc++.h> #define pb push_back #define sz(x) (int)(x.size()) #define all(x) x.begin(), x.end() #define int long long #define pii pair<int, int> #define inf 1e9 #define mod 1000000007 #define F first #define S second #define mkp(x, y) make_pair(x, y) #define wopen(x) freopen((x),"w",stdout) #define ropen(x) freopen((x),"r",stdin) #define de(x) cout << #x << " = " << x << ' ' #define IO ios_base::sync_with_stdio(0); cin.tie(0); using namespace std; const int mxN = 2e6 + 5; int k, n, s[mxN], t[mxN]; char p[mxN], q[mxN]; signed main() { IO; cin >> k >> n; vector<int> v; int ans = 0; for(int i = 0; i < n; i++) { cin >> p[i] >> s[i] >> q[i] >> t[i]; if(p[i] != q[i]) v.pb(s[i]), v.pb(t[i]), ans++; else ans += abs(s[i] - t[i]); } sort(all(v)); if(sz(v) == 0) { cout << ans << '\n'; return 0; } int mid = v[(sz(v)) / 2]; for(int i = 0; i < sz(v); i++) ans += abs(v[i] - mid); 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...