#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i=a; i<int(b); i++)
int main() {
int n,m;
cin >> n >> m;
vector<int>p(n+m-1);
vector<long long>c(n+m-1);
rep (i,0,n+m-1) {
cin >> p[i] >> c[i];
p[i]--; //0-indexed
}
if (n==1 && m<=100) {
rep (i,0,m) {
assert(p[i]==0);
}
sort(c.begin(),c.end());
long long goal=c[m/2];
long long ans=0;
rep (i,0,m) {
ans+=abs(goal-c[i]);
}
cout << ans << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
496 KB |
Output is correct |
3 |
Correct |
3 ms |
496 KB |
Output is correct |
4 |
Correct |
3 ms |
496 KB |
Output is correct |
5 |
Correct |
3 ms |
496 KB |
Output is correct |
6 |
Correct |
3 ms |
496 KB |
Output is correct |
7 |
Correct |
4 ms |
668 KB |
Output is correct |
8 |
Correct |
3 ms |
668 KB |
Output is correct |
9 |
Correct |
3 ms |
668 KB |
Output is correct |
10 |
Correct |
3 ms |
668 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
668 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
496 KB |
Output is correct |
3 |
Correct |
3 ms |
496 KB |
Output is correct |
4 |
Correct |
3 ms |
496 KB |
Output is correct |
5 |
Correct |
3 ms |
496 KB |
Output is correct |
6 |
Correct |
3 ms |
496 KB |
Output is correct |
7 |
Correct |
4 ms |
668 KB |
Output is correct |
8 |
Correct |
3 ms |
668 KB |
Output is correct |
9 |
Correct |
3 ms |
668 KB |
Output is correct |
10 |
Correct |
3 ms |
668 KB |
Output is correct |
11 |
Incorrect |
4 ms |
668 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
4 ms |
496 KB |
Output is correct |
3 |
Correct |
3 ms |
496 KB |
Output is correct |
4 |
Correct |
3 ms |
496 KB |
Output is correct |
5 |
Correct |
3 ms |
496 KB |
Output is correct |
6 |
Correct |
3 ms |
496 KB |
Output is correct |
7 |
Correct |
4 ms |
668 KB |
Output is correct |
8 |
Correct |
3 ms |
668 KB |
Output is correct |
9 |
Correct |
3 ms |
668 KB |
Output is correct |
10 |
Correct |
3 ms |
668 KB |
Output is correct |
11 |
Incorrect |
4 ms |
668 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |