QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#622963#8790. First Billionrns_rds#WA 1ms3604kbC++23781b2024-10-09 09:00:322024-10-09 09:00:32

Judging History

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

  • [2024-10-09 09:00:32]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3604kb
  • [2024-10-09 09:00:32]
  • 提交

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 (x >= n) return false;
		if (sum + a[x] == inf) {
			ans.push_back(x);
			return true;
		}
		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: 3532kb

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: 1ms
memory: 3604kb

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