結果

問題 No.2753 鳩の巣原理
ユーザー ttkkggww
提出日時 2024-05-14 14:09:45
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 51 ms / 2,000 ms
コード長 515 bytes
コンパイル時間 3,968 ms
コンパイル使用メモリ 251,952 KB
最終ジャッジ日時 2025-02-21 14:02:40
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include <iostream>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
int N;

void solve(){
	ll ok = 1,ng = N;
	for(int _ = 0;_<10;_++){
		ll mid = (ok+ng)/2;
		ll in;
		cout<< "? " << mid << endl;
		cout<< flush;
		cin >> in;
		if( mid <= in) {
			ok = min(ng-1,mid);
		}
		else{
			ng = max(ok+1,mid);
		}
	}
	cout<<"Yes "<<ok <<' '<<ng<<endl;
	cout<< flush;
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> N;
	solve();
}
0