# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
447464 | 2021-07-26T12:39:46 Z | snasibov05 | Fireworks (APIO16_fireworks) | C++14 | 0 ms | 0 KB |
#include <iostream> #include <vector> using namespace std; int main() { int n, m; cin >> n >> m; vector<int> p(m), c(m); for (int i = 0; i < m; ++i) cin >> p[i] >> c[i]; sort(c.begin(), c.end()); long long ans = 0; for (int i = 0; i < m; ++i) { ans += abs(c[i] - c[m/2]); } cout << ans << "\n"; return 0; }