QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#14393 | #3025. Assimilation | zin | WA | 208ms | 13852kb | C++17 | 772b | 2021-10-05 22:37:26 | 2022-05-17 00:27:39 |
Judging History
answer
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using t4 = tuple<ll, ll, ll, ll>;
int Z, N, K;
int arr[220000];
int main() {
cin >> Z;
while (Z--) {
cin >> N >> K;
for (int i = 0; i < N; i++) cin >> arr[i];
multiset<int> st;
ll sum = 0, k = K;
for (int i = 0; i < N; i++) st.insert(arr[i]), sum += arr[i];
int ans = 0;
while (st.size() && sum > k) {
auto iter = st.lower_bound(k);
if (iter == st.end() || *iter > k) {
if (iter != st.begin()) iter = prev(iter);
else break;
}
k += *iter;
sum -= *iter;
st.erase(iter);
ans++;
}
if (sum > k) cout << -1 << '\n';
else cout << ans << '\n';
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 208ms
memory: 13852kb
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 13566 4 -1 7 5385 9 2 -1 5 6264 3 0 -1 125010 5 -1 7 10940 1 3 100000 5 -1 -1
result:
wrong answer 6th lines differ - expected: '10621', found: '13566'