結果
| 問題 | No.1830 Balanced Majority |
| コンテスト | |
| ユーザー |
ぷら
|
| 提出日時 | 2022-02-04 22:38:27 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 888 bytes |
| 記録 | |
| コンパイル時間 | 1,368 ms |
| コンパイル使用メモリ | 209,852 KB |
| 実行使用メモリ | 30,032 KB |
| 平均クエリ数 | 18.92 |
| 最終ジャッジ日時 | 2026-06-25 04:54:14 |
| 合計ジャッジ時間 | 4,237 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | AC * 2 WA * 23 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
cout << "? " << N/2 << endl;
int S;
cin >> S;
if(S == 0) {
cout << "! " << 1 << " " << N/2 << endl;
return 0;
}
if(S == N/2) {
cout << "! " << 2 << " " << N-1 << endl;
return 0;
}
int l = N/2,r = N+1;
while (l < r) {
int mid = (l+r)/2;
cout << "? " << mid << endl;
int a;
cin >> a;
if(a == 0) {
cout << "! " << 1 << " " << mid << endl;
return 0;
}
if(a < 0 && S > 0) {
r = mid;
continue;
}
if(a > 0 && S < 0) {
r = mid;
continue;
}
if(N-mid == abs(a)) {
r = mid;
continue;
}
l = mid;
}
cout << "! " << 1 << " " << r << endl;
}
ぷら