結果
| 問題 |
No.253 ロウソクの長さ
|
| コンテスト | |
| ユーザー |
kurenai3110
|
| 提出日時 | 2016-09-27 22:55:41 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 627 bytes |
| コンパイル時間 | 431 ms |
| コンパイル使用メモリ | 58,844 KB |
| 実行使用メモリ | 25,604 KB |
| 平均クエリ数 | 3.00 |
| 最終ジャッジ日時 | 2024-07-16 11:06:51 |
| 合計ジャッジ時間 | 8,859 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 36 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int ask(int y) {
cout << "? " << y << endl;
int res;
cin >> res;
return res;
}
int main()
{
int cnt = 0;
int right=0, left = -100;
int Y = 10;
while (right<left) {
Y *= 2;
if (ask(Y) == -1)right = Y;
else if (ask(Y) == 0) {
cout << "! " << Y + cnt << endl;
return 0;
}
cnt++;
}
while (left < right) {
int mid = (left + right) / 2;
if (ask(mid) == -1)right = mid;
else if (ask(mid) == 0) {
cout << "! " << mid + cnt << endl;
return 0;
}
else left = mid+1;
cnt++;
right--; left--;
}
return 0;
}
kurenai3110