QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#235260#3025. Assimilationszaranczuk#WA 54ms5016kbC++17962b2023-11-02 16:32:202023-11-02 16:32:21

Judging History

你现在查看的是最新测评结果

  • [2023-11-02 16:32:21]
  • 评测
  • 测评结果:WA
  • 用时:54ms
  • 内存:5016kb
  • [2023-11-02 16:32:20]
  • 提交

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'