QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#624060 | #8034. Ban or Pick, What's the Trick | asaltfish | WA | 2ms | 3780kb | C++23 | 1.2kb | 2024-10-09 14:51:08 | 2024-10-09 14:51:09 |
Judging History
answer
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string.h>
#include<iomanip>
#include<stack>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<set>
#define ll long long
#define endl "\n"
using namespace std;
const ll mod = 1e9 + 7;
vector<ll>e[1000005];
ll n, t, k, p;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n >> k;
priority_queue<ll>a, b;
ll ansa = 0, ansb = 0, numa = 0, numb = 0;
for (int i = 1; i <= n; i++)
{
cin >> p;
a.push(p);
}
for (int i = 1; i <= n; i++)
{
cin >> p;
b.push(p);
}
while (a.size() && (numa <= k || numb <= k))
{
if (a.empty() || numa == k || (b.size() && a.top() < b.top()))
{
b.pop();
}
else
{
ansa += a.top();
numa++;
a.pop();
}
if (b.empty() || numb == k || (a.size() && b.top() < a.top()))
{
a.pop();
}
else
{
ansb += b.top();
numb++;
b.pop();
}
}
cout << ansa - ansb;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 3552kb
input:
2 1 3 6 2 4
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3552kb
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: 3776kb
input:
4 2 4 6 7 9 2 5 8 10
output:
3
result:
ok single line: '3'
Test #4:
score: 0
Accepted
time: 2ms
memory: 3616kb
input:
10 5 42 13 60 42 100 82 22 98 14 55 100 41 89 24 65 38 69 26 37 16
output:
41
result:
ok single line: '41'
Test #5:
score: 0
Accepted
time: 1ms
memory: 3780kb
input:
9 10 4 32 566 885 439 479 332 95 432 409 140 704 26 558 781 457 356 404
output:
58
result:
ok single line: '58'
Test #6:
score: -100
Wrong Answer
time: 2ms
memory: 3548kb
input:
20 8 249 888 548 338 840 890 519 416 852 817 28 694 271 947 239 11 654 914 765 939 483 148 403 552 250 635 287 644 364 822 621 151 31 422 683 959 867 266 837 395
output:
1241
result:
wrong answer 1st lines differ - expected: '1201', found: '1241'