結果

問題 No.1830 Balanced Majority
ユーザー se1ka2se1ka2
提出日時 2022-02-04 21:58:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 585 bytes
コンパイル時間 480 ms
コンパイル使用メモリ 64,348 KB
実行使用メモリ 24,036 KB
平均クエリ数 0.23
最終ジャッジ日時 2023-09-02 04:49:59
合計ジャッジ時間 4,160 ms
ジャッジサーバーID
(参考情報)
judge13 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
24,036 KB
testcase_01 AC 25 ms
7,808 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;

int main()
{
	int n;
	cin >> n;
	int s0, s1;
	cout << "? " << 1 << endl;
	cin >> s0;
	cout << "? " << n - 1 << endl;
	cin >> s1;
	if(s0 != n / 2 - s1){
		cout << "! " << 2 << " " << n - 1 << endl;
		return 0;
	}
	int right = n, left = 0;
	bool f = s0;
	while(right - left > 1){
		int mid = (right + left) / 2;
		int s;
		cin >> s;
		if(s * 2 == mid){
			if(mid * 2 > n) cout << "! " << 1 << " " << mid << endl;
			else cout << "! " << mid + 1 << " " << n << endl;
			return 0;
		}
		if((s * 2 > mid) == f) left = mid;
		else right = mid;
	}
}
0