結果

問題 No.3627 Share the Median
コンテスト
ユーザー Kude
提出日時 2026-08-15 01:09:48
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 57 ms / 1,000 ms
+ 0µs
コード長 1,734 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,432 ms
コンパイル使用メモリ 362,200 KB
実行使用メモリ 9,444 KB
平均クエリ数 7.60
最終ジャッジ日時 2026-08-15 01:09:59
合計ジャッジ時間 6,186 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
サブタスク 配点 結果
Sample 0 %
Easy 20 % AC * 16
Hard 80 % AC * 24
合計 3 * 100% = 300 点
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
namespace {
#pragma GCC diagnostic ignored "-Wunused-function"
#include<atcoder/all>
#pragma GCC diagnostic warning "-Wunused-function"
using namespace std;
using namespace atcoder;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;

} int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string player;
  cin >> player;
  int side = player == "Alice" ? 0 : 1;
  int q, n, m;
  cin >> q >> n >> m;
  vector<P> a(n), b(m);
  if (side == 0) {
    rep(i, n) cin >> a[i].first, a[i].second = i;
  } else {
    rep(i, m) cin >> b[i].first, b[i].second = i;
  }
  sort(all(a));
  sort(all(b));
  if (n < m) swap(a, b), swap(n, m), side ^= 1;
  int half = (n + m - 1) / 2 + 1;
  int l = half - m - 1, r = half + 1;
  int ans = 0;
  while (r - l > 1) {
    int c = (l + r) / 2;
    int d = half - c;
    int va = a[n-c].first, vb = d == 0 ? 1001001001 : b[m-d].first;
    if (side == 0) cout << "share " << a[n-c].second + 1 << endl;
    else cout << "share " << (d == 0 ? 0 : b[m-d].second) + 1 << endl;
    int res;
    cin >> res;
    if (d == 0) {
      if (side == 1) va = res;
    } else {
      (side == 0 ? vb : va) = res;
    }
    chmax(ans, min(va, vb));
    (va >= vb ? l : r) = c;
  }
  cout << "answer " << ans << endl;
}
0