QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#623116 | #8790. First Billion | rns_rds# | WA | 0ms | 3840kb | C++23 | 755b | 2024-10-09 10:14:24 | 2024-10-09 10:14:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) cin >> a[i];
sort(a.rbegin(), a.rend());
vector<int> ans;
const int inf = 1e9;
auto dfs = [&](auto self, int x, int sum) {
if (sum == inf) return true;
if (x == n || sum > inf) return false;
if (sum + a[x] <= inf) {
ans.push_back(x);
auto val = self(self, x + 1, sum + a[x]);
if (val == true) return true;
ans.pop_back();
}
auto val = self(self, x + 1, sum);
return val;
};
dfs(dfs, 0, 0);
cout << ans.size() << " ";
for (auto i : ans) cout << i + 1 << " ";
cout << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3840kb
input:
10 386413329 88494216 245947398 316438989 192751270 204627269 65749456 3938400 150458676 345180997
output:
5 1 5 6 7 9
result:
ok OK (n = 10)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3524kb
input:
10 119486233 299942886 169540407 349937991 597883752 32230162 140514533 57341098 12602102 220520836
output:
5 1 3 8 9 10
result:
wrong answer need sum 1000000000, got sum 579490676