QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#623116#8790. First Billionrns_rds#WA 0ms3840kbC++23755b2024-10-09 10:14:242024-10-09 10:14:28

Judging History

你现在查看的是最新测评结果

  • [2024-10-09 10:14:28]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3840kb
  • [2024-10-09 10:14:24]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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