QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#236185 | #3025. Assimilation | ahsoltan# | WA | 49ms | 5424kb | C++20 | 1.4kb | 2023-11-03 17:55:41 | 2023-11-03 17:55:41 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define x first
#define y second
#define ir(x,a,b) ((a) <= (x) && (x) <= (b))
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define foru(i, n) for (int i = 0; i < n; ++i)
#define fori(i,a,n) for (int i = a; i < n; ++i)
// #ifdef LOCAL
// auto& operator<<(auto&, pair<auto, auto>);
// template<typename T, typename = T::value_type>
// auto& operator<<(auto& o, T x) requires (!same_as<T, string>) {
// o << "{";
// string s;
// for (auto i : x) {
// o << s << i;
// s << ", ";
// }
// return o << "}";
// }
// auto& operator<<(auto& o, pair<auto, auto> p) {
// return o << "(" << p.first << ", " << p.second << ")";
// }
// #define debug(x..) cerr << "["#x"]:",[](auto...$){((cerr<<" "<<$),...)<<endl;}(x)
// #else
// #define debug(...) 2137
// #endif
void solve() {
set<ll> S;
ll n, k;
cin >> n >> k;
ll sum = 0;
foru (i, n) {
ll x;
cin >> x;
sum += x;
S.insert(x);
}
int ct = 0;
while (k < sum) {
auto it = S.upper_bound(k);
if (it == S.begin()) {
cout << "-1\n";
return;
}
--it;
++ct;
k += (*it);
sum -= (*it);
// cout << "taking " << *it << endl;
// cout << sum << " " << k << endl;
S.erase(it);
}
cout << ct << "\n";
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int z;
cin >> z;
while (z--) solve();
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 49ms
memory: 5424kb
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 2 3 -1 10943 4 -1 -1 5858 8 2 -1 5 6566 3 0 -1 -1 -1 -1 7 -1 1 3 -1 5 -1 -1
result:
wrong answer 1st lines differ - expected: '4', found: '-1'