結果
| 問題 | No.1830 Balanced Majority | 
| コンテスト | |
| ユーザー |  se1ka2 | 
| 提出日時 | 2022-02-04 21:47:38 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 604 bytes | 
| コンパイル時間 | 534 ms | 
| コンパイル使用メモリ | 63,872 KB | 
| 実行使用メモリ | 25,856 KB | 
| 平均クエリ数 | 11.54 | 
| 最終ジャッジ日時 | 2024-06-11 11:41:03 | 
| 合計ジャッジ時間 | 2,497 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 1 | 
| other | AC * 4 WA * 21 | 
ソースコード
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	cout << "? " << n / 2 << endl;
	int s;
	cin >> s;
	if(s == n / 2 || s == 0){
		cout << "! " << 2 << " " << n - 1 << endl;
		return 0;
	}
	if(s * 2 == n){
		cout << "! " << 1 << " " << n << endl;
		return 0;
	}
	bool f = true;
	if(s * 2 < n) f = false;
	int left = 0, right = n;
	while(right - left > 1){
		int mid = (right + left) / 2;
		cout << mid << endl;
		int s;
		cin >> s;
		if(s * 2 == mid){
			cout << "! " << mid + 1 << " " << n * 2 << endl;
			return 0;
		}
		if((s * 2 < n) == f) left = mid;
		else right = mid;
	}
}
            
            
            
        