QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#236215 | #3025. Assimilation | ahsoltan# | WA | 244ms | 12988kb | C++20 | 1.4kb | 2023-11-03 18:29:17 | 2023-11-03 18:29:18 |
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;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 244ms
memory: 12988kb
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 taking 1 9 2 taking 2 7 4 taking 1 6 5 taking 1 5 6 4 7 1 taking 1 6 2 taking 2 4 4 2 1198628815 316660370 taking 295093544 903535271 611753914 taking 346785866 556749405 958539780 2 230615703 43402885 taking 40095941 190519762 83498826 taking 44913378 145606384 128412204 taking 43810814 101795...
result:
wrong answer 1st lines differ - expected: '4', found: '10 1'