QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#630742#8936. Team Arrangementwoodie_0064#WA 0ms4004kbC++141.2kb2024-10-11 20:15:032024-10-11 20:15:04

Judging History

This is the latest submission verdict.

  • [2024-10-11 20:15:04]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 4004kb
  • [2024-10-11 20:15:03]
  • Submitted

answer

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;
int n, a[65], ans = -inf;
vector<int> R[65];
void dfs(int sz, vector<int> s, int sum) {
	if(!s.empty() && s.back() < sz) {
		return;
	}
	if(sz == n + 1) {
		ans = max(ans, sum);
		return;
	}
	vector<int> t;
	int i = 0, j = 0;
	while(i < (int)s.size() && j < (int)R[sz].size()) {
		if(s[i] > R[sz][j]) {
			t.push_back(s[i]);
			i++;
		}
		else {
			t.push_back(R[sz][j]);
			j++;
		}
	}
	for(int x = i; x < (int)s.size(); x++) {
		t.push_back(s[x]);
	}
	for(int x = j; x < (int)R[sz].size(); x++) {
		t.push_back(R[sz][x]);
	}
	dfs(sz + 1, t, sum);
	int x = 0;
	while((int)t.size() >= sz) {
		t.resize((int)t.size() - sz);
		x += sz;
		dfs(sz + 1, t, sum + a[x]);
	}
}
int main(){
	freopen("test.txt", "r", stdin);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for(int i = 1, l, r; i <= n; i++) {
		cin >> l >> r;
		R[l].push_back(r);
	}
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for(int i = 1; i <= n; i++) {
		sort(R[i].begin(), R[i].end(), greater<int>());
	}
	dfs(1, vector<int>(0), 0);
	if(ans == -inf) {
		cout << "impossible\n";
	} else {
		cout << ans << '\n';
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 4004kb

input:

3
2 3
1 2
2 2
4 5 100

output:

0

result:

wrong answer 1st lines differ - expected: '9', found: '0'