제출 #1164251

#제출 시각아이디문제언어결과실행 시간메모리
1164251ali2241Palembang Bridges (APIO15_bridge)C++20
0 / 100
0 ms464 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> // #define int long long #define arr2 array<int, 2> #define arr3 array<int, 3> #define all(a) a.begin(), a.end() #define double long double // #pragma GCC target("avx2") using namespace std; using namespace __gnu_pbds; template<class T> using rb3 = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template<class T> using mrb3 = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; const int N = 1e5 + 10, M = 998244353; int cost = 0; int abs(int a) { return (a < 0 ? -a : a); } void fun() { int k, n; cin >> k >> n; vector<int> pnt; for (int i = 0; i < n; ++i) { char a, c; int b, d; cin >> a >> b >> c >> d; if (a == c) { cost += d - b; } else { cost++; pnt.push_back(b); pnt.push_back(d); } } sort(all(pnt)); if (pnt.size()) { int mid = pnt[(pnt.size() + 1) / 2 - 1]; for (int i : pnt) { cost += abs(i - mid); } } cout << cost << "\n"; } int32_t main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); // int tc; // cin >> tc; // while (tc--) fun(); }
#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...