QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#606815#8936. Team ArrangementUESTC_xxx#WA 1ms8012kbC++141.2kb2024-10-03 12:25:532024-10-03 12:25:54

Judging History

This is the latest submission verdict.

  • [2024-10-03 12:25:54]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 8012kb
  • [2024-10-03 12:25:53]
  • Submitted

answer

#include<iostream>
#include<cstdio>
#include<cmath>
#include<queue>
#include<algorithm>
#define ll long long
using namespace std;
int n,a[1000005][62],b[62],cnt,ff[62],c[100];
void dfs(int t,int sum){
	if(t==1){
		cnt++,a[cnt][1]=n-sum;
		for(int i=2;i<=n;++i) a[cnt][i]=b[i];
		return;
	}
	for(int i=0;sum+i*t<=n;++i){
		b[t]=i;
		dfs(t-1,sum+i*t);
	}
}
struct node{
	int l,r;
}p[500005];
ll w[500005],ans=-1e18;
bool cmp(node x,node y){
	if(x.l==y.l) return x.r<y.r;
	return x.l<y.l;
}
priority_queue<int,vector<int>,greater<int> >q;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i) scanf("%d%d",&p[i].l,&p[i].r);
	sort(p+1,p+n+1,cmp);
	for(int i=1;i<=n;++i) scanf("%lld",&w[i]);
	dfs(n,0);
	for(int i=1;i<=cnt;++i){
		ll val=0;
		for(int j=1;j<=n;++j) val+=w[j]*a[i][j],ff[j]=j*a[i][j],c[j]=0;
		int now=1,flag=0,s=1;
		
		for(int j=1;j<=n;++j){
			while(p[now].l==j) c[p[now].r]++,now++;
			s=max(j,s);
			while(ff[j]){
				while(c[s]==0&&s<=n) s++;
				if(c[s])
				{
					c[s]--;
					ff[j]--;
				}else
				{
					flag=1;
					break;
				}
				
			}
			if(flag) break;
		}
		if(flag) continue;
		ans=max(ans,val);
	}
	if(ans==-1e18) printf("impossible");
	else printf("%lld",ans);
}

詳細信息

Test #1:

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

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

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

input:

2
1 1
2 2
1 1

output:

impossible

result:

ok single line: 'impossible'

Test #4:

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

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: 1ms
memory: 8012kb

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'