QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#235432 | #3025. Assimilation | piratZnachor# | WA | 118ms | 12748kb | C++14 | 1.1kb | 2023-11-02 19:18:36 | 2023-11-02 19:18:37 |
Judging History
answer
#include <bits/stdc++.h>
#include <cassert>
using namespace std;
//#define int long long
#define all(x) x.begin(), x.end()
#define pb push_back
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define vll vector<long long>
#define fi first
#define se second
void test_case() {
int n;
ll x;
cin >> n >> x;
ll sum = 0;
multiset<int> S;
for (int i = 0; i < n; i ++) {
int a;
cin >> a;
S.insert(a);
sum += a;
}
int res = 0;
while (x < sum && S.size() > 0) {
auto it = S.upper_bound(x);
if (it == S.begin()) {
cout << -1 << '\n';
return;
}
it --;
int y = *it;
S.erase(it);
sum -= y;
x += y;
res ++;
}
cout << res << '\n';
}
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int tc = 1;
cin >> tc;
while(tc--) {
test_case();
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 118ms
memory: 12748kb
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:
4 2 2 3 -1 -1 4 -1 7 5385 -1 2 -1 5 6264 3 0 -1 -1 5 -1 7 10940 1 3 100000 5 -1 -1
result:
wrong answer 6th lines differ - expected: '10621', found: '-1'