QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#236220 | #3025. Assimilation | ahsoltan# | WA | 117ms | 12856kb | C++20 | 1.4kb | 2023-11-03 18:31:05 | 2023-11-03 18:31:05 |
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() {
multiset<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;
cout << sum << " " << k << endl;
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 117ms
memory: 12856kb
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:
10 1 4 7 1 2 1198628815 316660370 2 230615703 43402885 3 85039134 319594 -1 9723995866466 110699531 10621 37 2 4 16 3 -1 43 1 7 178083043 3738 5385 5033164234 336763011 8 37 15 2 25 1 -1 120 5 5 410178985 2489 6264 11 1 3 997123123 1000000000 0 3545898325 74644350 -1 149981999349860 17 124764 24 1 5...
result:
wrong answer 1st lines differ - expected: '4', found: '10 1'