QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#130120 | #5653. Library game | bai_hong | TL | 0ms | 0kb | C++20 | 1.2kb | 2023-07-23 16:53:00 | 2023-07-23 16:53:02 |
Judging History
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");
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