結果
| 問題 |
No.1830 Balanced Majority
|
| コンテスト | |
| ユーザー |
se1ka2
|
| 提出日時 | 2022-02-04 21:42:40 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 600 bytes |
| コンパイル時間 | 623 ms |
| コンパイル使用メモリ | 65,196 KB |
| 実行使用メモリ | 25,964 KB |
| 平均クエリ数 | 2.00 |
| 最終ジャッジ日時 | 2024-06-11 11:38:46 |
| 合計ジャッジ時間 | 2,819 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 25 |
ソースコード
#include <iostream>
using namespace std;
int main()
{
int n;
cin >> n;
cout << "? " << n << endl;
int s;
cin >> s;
if(s == n || s == 0){
cout << "! " << 2 << " " << n * 2 - 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) right = mid;
else left = mid;
}
}
se1ka2