QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#589166 | #8936. Team Arrangement | ucup-team093# | WA | 1ms | 3848kb | C++20 | 1.2kb | 2024-09-25 16:29:19 | 2024-09-25 16:29:19 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const int N = 61;
int n, l[N], r[N], w[N];
void update(map<i64, int> &mp, i64 a, int b) {
if(!mp.count(a)) mp[a] = b;
else if(mp[a] < b) mp[a] = b;
}
int main() {
cin >> n;
for(int i = 0; i < n; i ++) cin >> l[i] >> r[i];
for(int i = 1; i <= n; i ++) cin >> w[i];
map<i64, int> mp;
mp[0] = 0;
for(int i = 1; i <= n; i ++) {
vector<int> v;
for(int j = 0; j < n; j ++) if(l[j] <= i && i <= r[j]) v.push_back(j);
sort(v.begin(), v.end(), [](int a, int b) {return r[a] < r[b];});
map<i64, int> nxt;
for(auto [idx, val] : mp) {
update(nxt, idx, val);
int cnt = 0;
i64 k = idx;
for(int x : v) {
if(!((idx >> x) & 1)) {
k |= 1ll << x;
cnt ++;
if(cnt == i) {
cnt = 0;
update(nxt, k, val + w[i]);
}
}
}
}
swap(nxt, mp);
}
if(mp.count((1ll << n) - 1)) cout << mp[(1ll << n) - 1];
else cout << "impossible";
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3612kb
input:
3 2 3 1 2 2 2 4 5 100
output:
9
result:
ok single line: '9'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
3 1 3 3 3 2 3 1 1 100
output:
100
result:
ok single line: '100'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
2 1 1 2 2 1 1
output:
impossible
result:
ok single line: 'impossible'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3608kb
input:
3 2 3 1 2 2 2 -100 -200 100000
output:
-300
result:
ok single line: '-300'
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3612kb
input:
9 1 4 2 5 3 4 1 5 1 1 2 5 3 5 1 3 1 1 1 1 1 1 1 1 1 1 1
output:
3
result:
wrong answer 1st lines differ - expected: '6', found: '3'