QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#723346 | #3025. Assimilation | Markadiusz# | WA | 55ms | 5496kb | C++23 | 1003b | 2024-11-07 21:54:23 | 2024-11-07 21:54:23 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
#define FOR(i,l,r) for(int i=(l);i<=(r);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define ssize(x) int(x.size())
#ifdef DEBUG
auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";}
auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";}
#define debug(X...) cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X)
#else
#define debug(...) {}
#endif
int main() {
cin.tie(0)->sync_with_stdio(0);
int tests;
cin >> tests;
REP (test, tests) {
int n, k;
cin >> n >> k;
LL cur = k;
LL sum = 0;
set<LL> s;
REP (i, n) {
int x;
cin >> x;
s.emplace(x);
sum += x;
}
int ans = 0;
while (ssize(s)) {
if (cur >= sum) {
break;
}
auto ptr = s.upper_bound(cur);
if (ptr == s.begin()) {
ans = -1;
break;
}
--ptr;
sum -= *ptr;
++ans;
cur += *ptr;
s.erase(ptr);
}
cout << ans << '\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 55ms
memory: 5496kb
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:
2 2 2 3 -1 10943 4 -1 5 5858 8 2 -1 5 6566 3 0 -1 -1 3 -1 7 6019 1 3 1 5 -1 -1
result:
wrong answer 1st lines differ - expected: '4', found: '2'