QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#648736#8936. Team ArrangementargtargWA 0ms3880kbC++201.3kb2024-10-17 20:09:562024-10-17 20:09:58

Judging History

This is the latest submission verdict.

  • [2024-10-17 20:09:58]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3880kb
  • [2024-10-17 20:09:56]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define pii pair<int, int>
void solve();

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int T = 1;
//    cin >> T;
    while (T--)solve();
    return 0;
}
void solve(){
    int n;
    cin>>n;
    vector<pii>a(n+1);
    for(int i=1;i<=n;i++){
        cin>>a[i].second>>a[i].first;
    }
    sort(a.begin()+1,a.end());
    int ans=-1e10;
    vector<int>num(n+1),w(n+1);
    for(int i=1;i<=n;i++){
        cin>>w[i];
    }
    auto dfs=[&](auto dfs,int re,int x)->void{
        if(x==0){
            if(re)return;
            int tmp=0,ok=1,l=1;
            for(int i=1;i<=n;i++){
//                cout<<num[i]<<' ';
                tmp+=num[i]*w[i];
                for(int j=0;j<num[i]*i;j++,l++){
                    if(!(a[l].second<=i&&a[l].first>=i))ok=0;
                }
            }
//            cout<<endl;
            if(ok==1&&l==n+1)ans=max(ans,tmp);
            return;
        }
        for(int j=0;j<=re;j+=x){
            num[x]=j/x;
            dfs(dfs,re-j,min(x-1,re-j));
            num[x]=0;
        }
    };
    dfs(dfs,n,n);
    cout<<(ans==-1e10 ? "impossible":to_string(ans))<<endl;
}

詳細信息

Test #1:

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

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

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

input:

2
1 1
2 2
1 1

output:

impossible

result:

ok single line: 'impossible'

Test #4:

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

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

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:

5

result:

wrong answer 1st lines differ - expected: '6', found: '5'