QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#555887#8034. Ban or Pick, What's the Trickcode_side-effectWA 0ms3676kbC++20577b2024-09-10 11:45:182024-09-10 11:45:18

Judging History

This is the latest submission verdict.

  • [2024-09-10 11:45:18]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3676kb
  • [2024-09-10 11:45:18]
  • Submitted

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;
}

詳細信息

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'