QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#606883#8936. Team ArrangementKomorebie#WA 1ms3864kbC++171.9kb2024-10-03 12:51:152024-10-03 12:51:15

Judging History

This is the latest submission verdict.

  • [2024-10-03 12:51:15]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 3864kb
  • [2024-10-03 12:51:15]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define maxn 70
#define ll long long
ll w[maxn], maxx = LLONG_MIN;
int  n, cnt[maxn], tot;

struct edge
{
    int l, r;
} b[maxn];

vector<int> to[maxn];
priority_queue<int, vector<int>, greater<int> > p;
void dfs(int x, int y, ll ans)
{ // to[x] 已经入队
    priority_queue<int, vector<int>, greater<int> > p0 = p;
    priority_queue<int, vector<int>, greater<int> > p1; // 记录的是原先r的情况
    if (p.top() >= y && y >= tot)
    {
        for (int i = x + 1; i <= y; i++)
        { // 处理剩余部分全部入帐的情况
            for (int j = 0; j < to[i].size(); j++)
            {
                p.push(to[i][j]);
            }
        }
        if (p.top() <= y)
        { // 全部入队了
            maxx = max(ans + w[y], maxx);
        }
    }

    for (int i = x; i * 2 <= y; i++)
    {
        if (p.top() < i)
            break;

        if (i != x)
        {
            for (int j = 0; j < to[i].size(); j++)
            {
                p.push(to[i][j]);
            }
        }
        p1=p;
        if (p.size() >= i)
        {
            for (int j = 1; j <= i; j++)
            {
                p.pop();
            }
            dfs(i, y - i, ans + w[i]);
        }
        p = p1; // 回退
    }
    p = p0; // 回退
    return ;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> b[i].l >> b[i].r;
        to[b[i].l].push_back(b[i].r);
        tot = max(tot, b[i].l);
    }
    for(int i=1;i<=n;i++){
        cin>>w[i];
    }
    for(int i=0;i<to[1].size();i++){
        p.push(to[1][i]);
    }
    dfs(1,n,0);
    if(maxx==LLONG_MIN){
        cout << "impossible"<<endl;
    }
    else {
        cout<<maxx<<endl;
    }
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3604kb

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

input:

3
1 3
3 3
2 3
1 1 100

output:

100

result:

ok single line: '100'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3628kb

input:

2
1 1
2 2
1 1

output:

impossible

result:

ok single line: 'impossible'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3576kb

input:

3
2 3
1 2
2 2
-100 -200 100000

output:

-300

result:

ok single line: '-300'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3572kb

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:

6

result:

ok single line: '6'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3864kb

input:

14
3 3
1 2
2 3
2 3
2 3
1 1
2 3
1 3
3 3
1 3
1 3
1 2
2 3
1 3
-9807452 -9610069 4156341 2862447 6969109 -7245265 -2653530 -5655094 6467527 -6872459 3971784 7312155 9766298 -2719573

output:

-16558567

result:

ok single line: '-16558567'

Test #7:

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

input:

14
1 2
1 4
2 3
3 5
4 5
2 5
2 4
2 4
1 2
3 4
1 5
2 4
1 1
4 5
-13763 -7354207 1096407 -9063321 -4824546 -6275546 1258145 -5272834 -8631107 3581157 2320771 -7714508 8446625 -6816167

output:

-2673021

result:

ok single line: '-2673021'

Test #8:

score: -100
Wrong Answer
time: 1ms
memory: 3640kb

input:

14
2 3
4 4
1 7
3 6
3 4
1 1
1 4
4 7
3 7
1 7
2 3
6 6
1 1
3 6
2923142 1686477 640352 2848353 9202543 -4441381 4866381 -3610520 8124124 -1372894 1111310 -7538627 466143 9937961

output:

17008761

result:

wrong answer 1st lines differ - expected: '5939733', found: '17008761'