QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#130114 | #5653. Library game | Fffoooo | RE | 0ms | 0kb | C++20 | 1.3kb | 2023-07-23 16:43:04 | 2023-07-23 16:43:07 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=100,M=5000;
int n,m,a[N];
bool vis[N];
bool cmp(int x,int y) { return x>y; }
int solve() {
sort(a+1,a+1+n,cmp);
for(int i=1;i<=n;i++) if( a[i]>( m/i ) ) { return a[i]; }
return 0;
}
int id=1;
pair<int,int> solve1( int p ) {
vis[p]=true;
int lent=0,x=1,y=0;
for(int i=1;i<=m;i++) {
if( vis[i] ) {
if( lent>=a[id] && lent<y ) y=lent,x=i-lent+1;
lent=0;
}
lent++;
}
return make_pair( a[id],x );
}
int di;
int solve2( pair<int,int> z ) {
int x=z.first,y=z.second;
for(int i=x;i<=y;i++) if( i%di==0 ) return i;
return x;
}
int main() {
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
di=solve();// cout<<di<<" ";
if( di==0 ) {
puts("Alessia");
fflush(stdout);
pair<int,int> ans=solve1(0);
printf("%d %d\n",ans.first,ans.second);
fflush(stdout);
for(int i=2;i<=n;i++) {
int x; scanf("%d",&x); id=i;
ans=solve1(x);
printf("%d %d\n",ans.first,ans.second);
fflush(stdout);
}
int x; scanf("%d",x);
} else {
puts("Bernardo");
fflush(stdout);
for(int i=1;i<=n;i++) {
int x,y; scanf("%d%d",&x,&y); di++;
int ans=solve2( make_pair( x-y+1,y ) );
printf("%d\n",ans);
fflush(stdout);
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
5 14 3 7 2 3 10 7 7 2 2 2
output:
Alessia 10 1 7 1 3 1 3 1 2 1