Submission #362577

#TimeUsernameProblemLanguageResultExecution timeMemory
362577flappybirdFireworks (APIO16_fireworks)C++14
7 / 100
1 ms364 KiB
#include <bits/stdc++.h> using namespace std; #define MAX 1010101 #define all(v) v.begin(), v.end() #define ln '\n' #define MOD 1000000007 #define INF 210000000000 #define pb push_back #define abs(x) (((x)>0)?(x):(-(x))) #define len(x) ((x).second-(x).first) typedef long long ll; ll C[MAX]; int main(void) { ios::sync_with_stdio(false); cin.tie(0); ll N, M; cin >> N >> M; ll i; ll p; for (i = 1; i <= M; i++) cin >> p >> C[i]; sort(C + 1, C + M + 1); ll a = C[(M + 1) / 2]; ll ans = 0; for (i = 1; i <= M; i++) ans += abs(a - C[i]); cout << ans << ln; 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...