QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#630742 | #8936. Team Arrangement | woodie_0064# | WA | 0ms | 4004kb | C++14 | 1.2kb | 2024-10-11 20:15:03 | 2024-10-11 20:15:04 |
Judging History
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'