제출 #636780

#제출 시각아이디문제언어결과실행 시간메모리
636780lovrotFireworks (APIO16_fireworks)C++11
7 / 100
1 ms300 KiB
#include <bits/stdc++.h> #define X first #define Y second #define pb push_back #define ll long long using namespace std; const ll INF = 1e15; ll abs2(ll x){ return x < 0 ? -x : x; } int n, m; vector<ll> v; int main(){ cin >> n >> m; for(int i = 2; i <= n + m; i++){ ll p, c; cin >> p >> c; v.pb(c); } sort(v.begin(), v.end()); ll ans = INF; if(v.size() == 1){ cout << "0\n"; return 0; } else { for(int c : v){ ll res = 0; for(int c2 : v){ res += abs2(c2 - c); } ans = min(ans, res); } } cout << ans << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...