QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#130121#5653. Library gamebai_hongTL 0ms0kbC++201.3kb2023-07-23 16:54:272023-07-23 16:54:31

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-23 16:54:31]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2023-07-23 16:54:27]
  • 提交

answer

#include<bits/stdc++.h>
const int QWQ=5005;
using namespace std;
inline int read(){
	char ch = getchar();int x = 0, f = 1;
	while(ch<'0'||ch>'9'){if(ch == '-') f = -1;ch = getchar();}
	while('0'<=ch && ch <= '9'){x = x*10+ch-'0';ch = getchar();}
	return x*f;
}
inline void write(int x){
	if(x <0)putchar('-'),x =-x;
	if(x >9)write(x /10);
	putchar(x %10+'0');
}
int n,m,a[QWQ],vis[QWQ];
bool cmp(int x,int y){ return x>y; }
bool cheak(){
	sort(a+1,a+n+1,cmp);
	for (int i=1;i<=n;i++)
		if (a[i]>m/i) return a[i];
	return 0;
}
signed main(){
	n=read(),m=read();
	for (int i=1;i<=n;i++) a[i]=read();
	int can=cheak();
	if (can){
		puts("Bernardo");
		fflush(stdout);
		vis[m+1]=1; int x;
		for (int i=2;i<=n;i++){
			x=read(),vis[x]=1;
			int tmp=114514,tp;
			for (int j=1,last=0;j<=m+1;j++)
				if (vis[j]){
					if (j-last-1>=a[i]&&j-last-1<tmp)
						tmp=j-last-1,tp=last+1;
					last=j;
				}
			printf("%d %d\n",a[i],tp);
			fflush(stdout);
		} x=read();
	} else{
		puts("Alessia");
		fflush(stdout);
		int x,l,r; bool fl=0;
		for (int i=n;i;i--){
			x=read(),l=read();
			r=l+x-1,fl=0;
			for (int j=l;j<=r;j++)
				if(!(j%can)){ fl=1; printf("%d\n",j); break; }
			if (!fl) printf("%d\n",l);
			fflush(stdout);
		}
	}
	return 0;
} 

详细

Test #1:

score: 0
Time Limit Exceeded

input:

5 14
3 7 2 3 10

output:

Alessia

result: