結果
問題 | No.253 ロウソクの長さ |
ユーザー |
![]() |
提出日時 | 2018-03-16 20:56:15 |
言語 | C++11 (gcc 13.3.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 649 bytes |
コンパイル時間 | 698 ms |
コンパイル使用メモリ | 56,452 KB |
実行使用メモリ | 40,268 KB |
平均クエリ数 | 8.81 |
最終ジャッジ日時 | 2024-07-17 01:39:48 |
合計ジャッジ時間 | 5,142 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 TLE * 1 -- * 18 |
ソースコード
#include<iostream>using namespace std;int timer = 0;int ask(int Y){cout << "? " << Y << endl;int res;cin >> res;timer++;return res;}int main(){int res = ask(100);int min = 10;int max = 1e9;int mid;if(res == 0){cout << "! " << 100 << endl;}else if(res < 0) max = 99;else min = 101;while(1){mid = min + (max-min)/2;res = ask(mid - timer);if(res == 0){cout << "! " << mid << endl;break;}else if(res == 1){min = mid+1;}else{max = mid-1;}}return 0;}