結果
| 問題 | No.3627 Share the Median |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-11-24 21:34:03 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 146 ms / 1,000 ms |
| + 999µs | |
| コード長 | 1,185 bytes |
| 記録 | |
| コンパイル時間 | 3,038 ms |
| コンパイル使用メモリ | 363,996 KB |
| 実行使用メモリ | 6,400 KB |
| 平均クエリ数 | 8.05 |
| 最終ジャッジ日時 | 2026-11-24 21:34:14 |
| 合計ジャッジ時間 | 9,060 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| Sample | 0 % | |
| Easy | 20 % | AC * 16 |
| Hard | 80 % | AC * 24 |
| 合計 | 3 * 100% = 300 点 |
ソースコード
#include <bits/stdc++.h>
#define All(x) x.begin(),x.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
using ll=long long;
signed main(){
IOS
string s;
int Q,n,m;
cin>>s>>Q>>n>>m;
bool alice=(s=="Alice");
int len=alice?n:m,k=(n+m+1)/2;
using PII=pair<int,int>;
vector<PII> a(len+1);
for(int i=1;i<=len;++i){
cin>>a[i].first;
a[i].second=i;
}
sort(a.begin()+1,a.end());
auto share=[&](int i){
cout<<"share "<<a[i].second<<endl;
int x; cin>>x;
if(x==-1) exit(0);
return x;
};
int l=max(0,k-m),r=min(n,k);
while(l<r){
int i=(l+r+1)/2;
int j=k-i+1;
int x,y;
if(alice){
x=a[i].first;
y=share(i);
} else{
x=share(j);
y=a[j].first;
}
if(x<=y) l=i;
else r=i-1;
}
int i=l,j=k-l;
int x,y;
if(alice){
x=i?a[i].first:0;
y=share(max(1,i));
if(!j) y=0;
} else{
y=j?a[j].first:0;
x=share(max(1,j));
if(!i) x=0;
}
cout<<"answer "<<max(x,y)<<endl;
}