QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#640903#8936. Team ArrangementmeiqwqWA 0ms3704kbC++231.2kb2024-10-14 16:49:302024-10-14 16:49:34

Judging History

This is the latest submission verdict.

  • [2024-10-14 16:49:34]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3704kb
  • [2024-10-14 16:49:30]
  • Submitted

answer


#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(i=j;i<=k;++i)
#define dow(i,j,k) for(i=j;i>=k;--i)
#define pr pair
#define mkp make_pair
#define fi first
#define se second
const int N=70;
int cnt[N],n,w[N],ans=1<<31,hsh[N][N];
pr<int,int>pp[N];
bool cmp(pr<int,int> A,pr<int,int>B){return A.se<B.se;}
void dfs(int s,int n,int cur,int sum){
    if(s==n){
        if(sum<=ans)return;
        int ptr=1,i,j,flg=1;
        rep(i,1,cur){
            rep(j,1,cnt[i]*i){
                if(pp[ptr].fi<=i && i<=pp[ptr].se)++ptr;
                else {flg=0;break;}
            }
            if(flg==0)break;
        }
        if(flg)ans=max(ans,sum);
        return;
    }
    if(s+cur>n)return;
    int i;
    for(i=0;i*(cur+1)+s<=n;++i){
        cnt[cur+1]=i;
        dfs(s+i*(cur+1),n,cur+1,sum+i*w[cur+1]);
    }
}
int main(){//freopen("in.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin>>n;
    int i,j;
    rep(i,1,n){
        int l,r;cin>>l>>r;pp[i]=mkp(l,r);
    }
    sort(pp+1,pp+1+n,cmp);
    rep(i,1,n)cin>>w[i];
    //rep(i,1,n)w[i]=-100;
    dfs(0,n,0,0);
    if(ans>(1<<31))cout<<ans;else cout<<"impossible";
}

詳細信息

Test #1:

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

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

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

input:

2
1 1
2 2
1 1

output:

impossible

result:

ok single line: 'impossible'

Test #4:

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

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

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'