QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#555887 | #8034. Ban or Pick, What's the Trick | code_side-effect | WA | 0ms | 3676kb | C++20 | 577b | 2024-09-10 11:45:18 | 2024-09-10 11:45:18 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using i64 = long long;
const int N = 1e5 + 5;
i64 a[N],b[N];
int main(){
int n , k;
cin >> n >> k;
for(int i = 1 ; i <= n;i++){
cin >> a[i];
}
for(int i = 1 ; i <= n;i++){
cin >> b[i];
}
sort(a+1,a+1+n);
sort(b+1,b+1+n);
i64 ans = 0;
for(int i = n ; i >= 1 ; i--){
if(k==0) break;
if(a[i] <= b[i]) continue ;
else{
ans+=(a[i] - b[i]);
k--;
}
}
cout << ans << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3544kb
input:
2 1 3 6 2 4
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3676kb
input:
4 1 1 3 5 7 2 4 6 8
output:
0
result:
ok single line: '0'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3536kb
input:
4 2 4 6 7 9 2 5 8 10
output:
3
result:
ok single line: '3'
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3612kb
input:
10 5 42 13 60 42 100 82 22 98 14 55 100 41 89 24 65 38 69 26 37 16
output:
45
result:
wrong answer 1st lines differ - expected: '41', found: '45'