Submission #739158

#TimeUsernameProblemLanguageResultExecution timeMemory
739158Alihan_8Fireworks (APIO16_fireworks)C++17
7 / 100
1 ms468 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define pb push_back #define ln '\n' #define int long long template <class _T> bool chmin(_T &x, const _T &y){ bool flag = false; if ( x > y ){ x = y; flag |= true; } return flag; } template <class _T> bool chmax(_T &x, const _T &y){ bool flag = false; if ( x < y ){ x = y; flag |= true; } return flag; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; vector <pair<int,int>> g[n + m]; vector <int> p; for ( int i = 1; i < n + m; i++ ){ int x, w; cin >> x >> w; g[--x].pb({i, w}); p.pb(w); } assert(n == 1); sort(all(p)); int res = 0; for ( auto i: p ){ res += abs(i - p[m >> 1]); } cout << res; cout << '\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...