QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#789449#8936. Team Arrangement_fcy_#WA 0ms3752kbC++141.8kb2024-11-27 20:23:092024-11-27 20:23:17

Judging History

This is the latest submission verdict.

  • [2024-11-27 20:23:17]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3752kb
  • [2024-11-27 20:23:09]
  • Submitted

answer

#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef pair<int,int> pii;
const int maxn=100+10;
vector <int> ver;
int inf=1e9+7;
int n,ans=-inf;
int vis[maxn],l[maxn],r[maxn],w[maxn];
void dfs(int x,int y){
    if(x==0){
        int val=0;
        for(auto u:ver){
            val+=w[u];
        }
        if(val<ans) return;
        vector <pii> t;
        for(int i=1;i<=n;i++){
            t.push_back({l[i],r[i]});
        }
        sort(ver.begin(),ver.end());
        sort(t.begin(),t.end(),[&](pii x,pii y){
            if(x.fi==y.fi) return x.se>y.se;
            else return x.fi<y.fi;
        });
        vector <int> vis(n,0);
        int flag=1;
        for(auto u:ver){
            int cnt=0;
            for(int i=0;i<n;i++){
                if(t[i].fi<=u&&u<=t[i].se&&vis[i]==0){
                    vis[i]=1; cnt++;
                    if(cnt==u) break;
                } 
            }
            if(cnt!=u){
                flag=0;
                break;
            }
        }
        // for(auto u:ver){
        //     cout<<u<<" ";
        // }
        // cout<<endl;
        // cout<<val<<endl;
        // cout<<"------\n";
        if(flag==1){
            ans=max(ans,val);
        }
        return;
    }
    for(int i=1;i<=min(x,y);i++){
        ver.push_back(i);
        dfs(x-i,i);
        ver.pop_back();
    }
}
signed main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>l[i]>>r[i];
        for(int j=l[i];j<=r[i];j++){
            vis[j]++;
        }
    }
    for(int i=1;i<=n;i++){
        cin>>w[i];
    }
    dfs(n,100);
    if(ans==-inf) cout<<"impossible\n";
    else cout<<ans<<"\n";
    return 0;
}

详细

Test #1:

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

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

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

input:

2
1 1
2 2
1 1

output:

impossible

result:

ok single line: 'impossible'

Test #4:

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

input:

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

output:

-300

result:

ok single line: '-300'

Test #5:

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

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: -100
Wrong Answer
time: 0ms
memory: 3620kb

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:

-10907456

result:

wrong answer 1st lines differ - expected: '-16558567', found: '-10907456'