結果
問題 |
No.253 ロウソクの長さ
|
ユーザー |
|
提出日時 | 2016-10-09 23:21:13 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,221 bytes |
コンパイル時間 | 1,575 ms |
コンパイル使用メモリ | 166,184 KB |
実行使用メモリ | 25,220 KB |
平均クエリ数 | 9.14 |
最終ジャッジ日時 | 2024-07-17 00:29:11 |
合計ジャッジ時間 | 5,525 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 TLE * 1 -- * 25 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr) #define all(x) (x).begin(),(x).end() #define pb push_back #define fi first #define se second int ct=0; int ask(int Y) { ++ct; cout << "? " << Y << endl; int res; cin >>res; return res; } int main() { int ans=-1; int res=ask(10); if(res==0) { printf("! 10\n"); return 0; } res=ask(90); if(res==0) ans=90; else if(res==-1) { while(res!=0) res=ask(9); ans=9+ct-1; } else { int l=90, r=1000000000; while(r-l>1) { // printf("l= %d, r= %d\n", l,r); int m=(l+r)/2; res=ask(m); if(res==0) { ans=m+ct-1; break; } else if(res==-1) { --l; r=m; } else { --r; l=m; } } if(ans==-1) ans=l+ct-1; } cout << "! " << ans << endl; return 0; }