QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#801544 | #8936. Team Arrangement | Noobie_99# | WA | 1ms | 3864kb | C++20 | 1.2kb | 2024-12-07 01:42:39 | 2024-12-07 01:42:41 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) ::begin(x), ::end(x)
void _d(auto... x) { ((cerr << ' ' << x), ...) << endl; }
#define debug(x...) cerr << "["#x"]:", _d(x)
int main() {
cin.tie(0)->sync_with_stdio(0);
int n;
cin >> n;
vector<pair<int, int>> a(n);
for (auto& [x, y] : a) cin >> y >> x;
sort(all(a));
vector<ll> c(n);
for (ll& e : c) cin >> e;
ll ans = 1e18;
auto idk = [&](auto& self, vector<pair<int, int>> b, ll cost, int mn) -> void {
vector<pair<int, int>> b2;
int tmp = 0;
for (auto& [r, l] : b) {
if (tmp < mn && l <= mn && mn <= r) {
tmp++;
} else {
b2.emplace_back(r, l);
}
}
if (tmp != mn) return;
if (mn != 0) cost += c[mn-1];
if (b2.empty()) {
ans = min(ans, cost);
return;
}
for (int i=max(1, mn); i<=ssize(b2); i++) {
self(self, b2, cost, i);
}
};
idk(idk, a, 0, 0);
if (ans > 1e17) cout << "impossible\n";
else cout << ans << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3640kb
input:
3 2 3 1 2 2 2 4 5 100
output:
9
result:
ok single line: '9'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3796kb
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: 3576kb
input:
2 1 1 2 2 1 1
output:
impossible
result:
ok single line: 'impossible'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3864kb
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: 3628kb
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:
4
result:
wrong answer 1st lines differ - expected: '6', found: '4'