QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#820690#8936. Team Arrangementkakakaa0#WA 0ms3812kbC++201.7kb2024-12-18 23:24:042024-12-18 23:24:06

Judging History

This is the latest submission verdict.

  • [2024-12-18 23:24:06]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3812kb
  • [2024-12-18 23:24:04]
  • Submitted

answer

#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
using namespace std;
const int maxn=2e5+10;
int ans=-inf; 
int n;
struct node{
   int l,r,id;
}a[66];
int w[66],c[66],b[66];
bool cmp(node x,node y)
{
    return x.l>y.l;
}
bool check(int cnt)
{
    for(int i=1;i<=n;i++) b[i]=0;
    for(int i=cnt;i>=1;i--)
    {
         vector<node> v;
		 for(int j=1;j<=n;j++)
		 {
		     if(b[j]==0)
		     {
		         if(a[j].l>c[i])
		         {
		            return 0;
				 }
				 if(a[j].r>=c[i])
				 {
				    v.pb(a[j]);
				 }
			 }
		 }
		 if(v.size()<c[i]) return 0;
		 sort(v.begin(),v.end(),cmp);
		 
//		 for(auto p:v)
//		 cout<<p.id<<"..";
//		 cout<<endl;
		 for(int j=0;j<c[i];j++)
		 b[v[j].id]=1;
	}
	return 1;
}
void dfs(int sum,int cnt)
{
    if(sum==n)
    {
//        for(int i=1;i<=cnt;i++)
//        cout<<c[i]<<" ";cout<<endl;
        if(check(cnt))
        {
            int res=0;
            for(int i=1;i<=cnt;i++)
            res+=w[c[i]];
            ans=max(ans,res);
            return;
		}
	}
	for(int i=c[cnt];i+sum<=n;i++)
	{
	    c[cnt+1]=i;
	    dfs(sum+i,cnt+1); 
	}
}
void kakakaa()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>a[i].l>>a[i].r,a[i].id=i;
    c[0]=1;
    
    for(int i=1;i<=n;i++)
    cin>>w[i];
	dfs(0,0);
	if(ans=-inf)
	cout<<"impossible";
	else
    cout<<ans;
}
signed main()
{
   ios::sync_with_stdio(false);//解除cin和cout的绑定,让它们可以独立缓冲
   cin.tie(0);
   cout.tie(0);
   kakakaa();
   return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3812kb

input:

3
2 3
1 2
2 2
4 5 100

output:

impossible

result:

wrong answer 1st lines differ - expected: '9', found: 'impossible'