QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#606889#8936. Team ArrangementUESTC_xxx#WA 2ms9928kbC++201.6kb2024-10-03 12:53:392024-10-03 12:53:39

Judging History

This is the latest submission verdict.

  • [2024-10-03 12:53:39]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 9928kb
  • [2024-10-03 12:53:39]
  • Submitted

answer

#include<iostream>
#include<cstdio>
#include<cmath>
#define lowbit(x) x&(-x)
#include<queue>
#include<algorithm>
#define ll long long
using namespace std;
int n,ti,a[1000005][62],b[62],cnt,ff[62],sz,h[50005];
void dfs(int t,int sum){
	ti++;
	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];
int w[500005],ans=-1e9;
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;
void ins(int x){
	sz++,h[sz]=x;
	int now=sz;
	while(now>1&&h[now/2]>h[now]) swap(h[now/2],h[now]),now/=2;
}
void del(){
	swap(h[1],h[sz]);
	sz--;
	int now=1;
	while(now*2<=sz){
		int k=now*2,fff=0;
		if(h[k]<h[now]&&k<=sz) now=k,fff=1;
		if(h[now]<h[k+1]&&k+1<=sz) now=k+1,fff=1;
		if(!fff) break;
		swap(h[now],h[now/2]);
	}
}
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("%d",&w[i]);
	dfs(n,0);
	for(int i=1;i<=cnt;++i){
		int val=0;
		for(int j=1;j<=n;++j) val+=w[j]*a[i][j],ff[j]=j*a[i][j];
		int now=1,flag=0;
		sz=0;
		for(int j=1;j<=n;++j){
			while(p[now].l==j) ins(p[now].r),now++;
			while(ff[j]){
				if(!sz){
					flag=1;
					break;
				}
				int x=h[1];
				if(x<j) flag=1;
				if(flag) break;
				del();
				ff[j]--;
			}
			if(flag) break;
		}
		if(flag) continue;
		ans=max(ans,val);
	}
	if(ans==-1e9) printf("impossible");
	else printf("%d",ans);
}

詳細信息

Test #1:

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

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

input:

3
1 3
3 3
2 3
1 1 100

output:

100

result:

ok single line: '100'

Test #3:

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

input:

2
1 1
2 2
1 1

output:

impossible

result:

ok single line: 'impossible'

Test #4:

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

input:

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

output:

-300

result:

ok single line: '-300'

Test #5:

score: 0
Accepted
time: 2ms
memory: 9928kb

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

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:

-53701456

result:

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