QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#235260 | #3025. Assimilation | szaranczuk# | WA | 54ms | 5016kb | C++17 | 962b | 2023-11-02 16:32:20 | 2023-11-02 16:32:21 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5 + 5;
int n;
ll k;
int w[N];
priority_queue<int> Q;
int main(){
cin.tie(0);
ios_base::sync_with_stdio(0);
int tc=1;
cin >>tc;
while(tc--){
cin >> n >> k;
for(int i=0;i<n;i++){
cin >> w[i];
}
bool ans = true;
while(Q.size()) Q.pop();
int ans2 = 0;
sort(w,w+n);
for(int i=0;i<n;i++){
while(w[i] > k){
if(!Q.size()){
ans = false;
break;
}
else{
k += Q.top(); ans2++;
Q.pop();
}
}
Q.push(w[i]);
}
if(!ans){
cout << "-1\n";
}
else{
cout << ans2 << "\n";
}
}
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 54ms
memory: 5016kb
input:
29 9 1 1 1 2 1 1 1 1 1 1 4 1 3 2 1 1 5 316660370 269357435 105688553 346785866 295093544 181703417 6 43402885 39947441 27068237 43810814 44913378 40095941 34779892 22 319594 3815194 3056481 6593888 7315914 6593888 4794774 2561877 5256242 4920603 5256242 3606645 864746 1594265 1235578 2361430 2277526...
output:
1 2 1 1 -1 3 3 -1 3 4 0 2 -1 2 5 2 0 -1 49774 2 -1 2 1 0 2 0 4 -1 -1
result:
wrong answer 1st lines differ - expected: '4', found: '1'