QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#801544#8936. Team ArrangementNoobie_99#WA 1ms3864kbC++201.2kb2024-12-07 01:42:392024-12-07 01:42:41

Judging History

This is the latest submission verdict.

  • [2024-12-07 01:42:41]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3864kb
  • [2024-12-07 01:42:39]
  • Submitted

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';
}

详细

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'