Submission #947290

#TimeUsernameProblemLanguageResultExecution timeMemory
947290NValchanovFireworks (APIO16_fireworks)C++17
7 / 100
1 ms432 KiB
#include<bits/stdc++.h> #define endl '\n' using namespace std; typedef long long ll; const ll MAXN = 3e5 + 10; ll n,m; ll w[MAXN]; void read() { cin >> n >> m; for(int i = 2; i <= n + m; i++) { ll p,c; cin >> p >> c; w[i] = c; } } void solve() { ll ans = 0; sort(w + 1, w + n + m + 1); ll mid = w[(n + m) / 2 + 1]; for(int i = 2; i <= n + m; i++) { ans += llabs(w[i] - mid); } cout << ans << endl; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); read(); solve(); 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...