QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#130144 | #5653. Library game | Fffoooo | RE | 2ms | 3732kb | C++20 | 1.3kb | 2023-07-23 17:11:25 | 2023-07-23 17:11:27 |
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 x=1,y=114514,lat=0;
for(int i=1;i<=m+1;i++) {
if( vis[i] ) {
//cout<<lent<<" "<<endl;
if( i-lat-1>=a[id] && i-lat-1<y ) y=i-lat-1,x=lat+1;
lat=i;
}
}
return make_pair( a[id],x );
}
int di;
int solve2( pair<int,int> z ) {
int x=z.first,y=z.second;
//cout<<x<<" "<<y<<" "<<di<<endl;
for(int i=x;i<=y;i++) if( i%di==0 ) return i;
return x;
}
int main() {
scanf("%d%d",&n,&m); vis[m+1]=true;
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
di=solve();// cout<<di<<" ";
if( di==0 ) {
puts("Alessia");
fflush(stdout);
printf("%d 1\n",a[1]);
fflush(stdout);
int x;
for(int i=2;i<=n;i++) {
scanf("%d",&x); id=i;
pair<int,int> ans=solve1(x);
printf("%d %d\n",ans.first,ans.second);
fflush(stdout);
}
scanf("%d",&x);/**/
} else {
puts("Bernardo");
fflush(stdout);
for(int i=1;i<=n;i++) {
int x,y; scanf("%d%d",&x,&y);
int ans=solve2( make_pair( y,y+x-1 ) );
printf("%d\n",ans);
fflush(stdout);
}
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3732kb
input:
5 14 3 7 2 3 10 7 14 2 4 6
output:
Alessia 10 1 7 8 3 1 3 3 2 5
result:
ok Contestant won the game
Test #2:
score: 0
Accepted
time: 2ms
memory: 3640kb
input:
4 10 4 1 6 4 6 1 4 5 4 6 1 9
output:
Bernardo 4 8 8 9
result:
ok Contestant won the game
Test #3:
score: -100
Runtime Error
input:
100 4000 584 96 57 44 47 123 325 102 145 58 46 324 62 80 66 84 45 44 84 159 451 55 95 76 41 63 54 302 67 40 407 48 51 443 2719 267 202 179 116 43 41 116 56 483 59 104 250 41 124 43 98 373 218 62 60 50 50 125 226 127 429 18 79 82 1884 48 70 46 165 75 43 261 68 42 59 40 50 49 76 70 43 104 69 1215 53 1...