# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
403696 | 2021-05-13T11:22:04 Z | CursedCode | Fireworks (APIO16_fireworks) | C++14 | 2 ms | 1740 KB |
#include<bits/stdc++.h> #include<algorithm> #include<vector> using namespace std; int main(){ int N,M,i,j; long long a[100000],as = 0,b[100000],x = 1000000000,y = 0,ans = 0,ansl = 1000000000; cin >> N >> M; for(i = 1;i <= N + M - 1;i++){ cin >> a[i] >> b[i]; } sort(b + 1,b + M); if(M%2 == 1){ for(i = 1;i <= N + M - 1;i++){ ans += abs(b[(M + 1)/2] - b[i]); } cout << ans; } else{ long long x = b[M / 2]; for(i = 1;i <= N + M - 1;i++){ ans += abs(x - b[i]); } x = b[M / 2 + 1]; for(i = 1;i <= N + M - 1;i++){ as += abs(x - b[i]); } cout << min(ans,as); } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1740 KB | Output is correct |
2 | Correct | 1 ms | 1740 KB | Output is correct |
3 | Incorrect | 2 ms | 1740 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 1740 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1740 KB | Output is correct |
2 | Correct | 1 ms | 1740 KB | Output is correct |
3 | Incorrect | 2 ms | 1740 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 1740 KB | Output is correct |
2 | Correct | 1 ms | 1740 KB | Output is correct |
3 | Incorrect | 2 ms | 1740 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |