結果
問題 | No.253 ロウソクの長さ |
ユーザー |
|
提出日時 | 2016-10-30 07:06:40 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 469 bytes |
コンパイル時間 | 471 ms |
コンパイル使用メモリ | 55,564 KB |
実行使用メモリ | 25,520 KB |
平均クエリ数 | 31.83 |
最終ジャッジ日時 | 2024-07-16 11:19:43 |
合計ジャッジ時間 | 7,708 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 36 |
ソースコード
#include <iostream> using namespace std; int ask(int Y){ cout << "? " << Y << endl; int res; cin >> res; return res; } int main(){ int ans = 0; int X = 0; int Y = 1000000000; int cnt=0; for(int i=0;i<100;i++){ int Z = (X+Y)/2; cnt+=1; int a=ask(Z); if(a==0){ ans = Z; break; } else if(a==1){ X=Z; } else if(a==-1){ Y=Z; } if(X>0) X-=1; if(Y>0) Y-=1; } ans+=cnt; cout << "! " << ans << endl; return 0; }