QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#542709#8936. Team Arrangementucup-team1231#WA 0ms4020kbC++141.0kb2024-09-01 04:23:532024-09-01 04:23:53

Judging History

This is the latest submission verdict.

  • [2024-09-01 04:23:53]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 4020kb
  • [2024-09-01 04:23:53]
  • Submitted

answer

#include <bits/stdc++.h>
#include <set>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
LL ans = INF;
int n, w[65];
pair<int, int> p[65];
vector<int> hv[65];
int vec[65], l;

void calc(LL c) {
    multiset<int> S;
    int j = 0;
    for(int i = 0; i < n; i++) {
        while(j < n && p[j].first <= vec[i]) S.insert(p[j++].second);
        if(S.empty() || *S.begin() < vec[i]) return;
        S.erase(S.begin());
    }
    ans = min(ans, c);
}

void dfs(int i, int s, LL c) {
    if(s == 0) calc(c);
    if(i > s) return;
    for(int j = i; j <= s; j++) {
        for(int k = 0; k < j; k++) vec[l++] = j;
        dfs(j, s - j, c + w[j]);
        l -= j;
    }
}

int main() {
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d%d", &p[i].first, &p[i].second);
    sort(p, p + n);
    for(int i = 1; i <= n; i++) scanf("%d", &w[i]);

    dfs(1, n, 0);
    if(ans == INF) printf("impossible\n");
    else printf("%lld\n", ans);
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3800kb

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: 4020kb

input:

2
1 1
2 2
1 1

output:

impossible

result:

ok single line: 'impossible'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3832kb

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: 3800kb

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'