結果

問題 No.2753 鳩の巣原理
ユーザー rieaaddlreiuurieaaddlreiuu
提出日時 2024-05-23 11:13:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 457 bytes
コンパイル時間 1,737 ms
コンパイル使用メモリ 166,348 KB
実行使用メモリ 25,580 KB
平均クエリ数 11.00
最終ジャッジ日時 2024-05-23 11:14:01
合計ジャッジ時間 6,400 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 23 ms
25,220 KB
testcase_02 AC 22 ms
25,220 KB
testcase_03 AC 23 ms
25,208 KB
testcase_04 WA -
testcase_05 AC 22 ms
25,208 KB
testcase_06 AC 23 ms
24,836 KB
testcase_07 AC 23 ms
24,964 KB
testcase_08 WA -
testcase_09 AC 22 ms
24,556 KB
testcase_10 WA -
testcase_11 AC 22 ms
24,812 KB
testcase_12 AC 23 ms
24,556 KB
testcase_13 AC 22 ms
24,812 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 21 ms
24,812 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 23 ms
24,556 KB
testcase_21 AC 23 ms
25,196 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 23 ms
25,568 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
	int data,N;
	int left,right,mid;
	cin >> N;
	left=1;
	right = N;
	for(int i=0;i<10;i++){
		mid = (left+right)/2;
		cout << "? " << mid << endl;
		cin >> data;
		if((left+right) % 2 == 0){
			if(data > mid){
			left = mid;
		} else {
			right = mid;
		}
		} else {
			if(data >= mid){
			left = mid;
		} else {
			right = mid;
		}
		}
	}
	cout << "Yes " << left << " " << right << endl;
	return 0;
}
0