結果
問題 | No.253 ロウソクの長さ |
ユーザー |
![]() |
提出日時 | 2015-07-24 23:41:28 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,022 bytes |
コンパイル時間 | 686 ms |
コンパイル使用メモリ | 82,452 KB |
実行使用メモリ | 39,984 KB |
最終ジャッジ日時 | 2024-07-16 05:03:02 |
合計ジャッジ時間 | 6,944 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | TLE * 1 -- * 35 |
ソースコード
#include<sstream> #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<string> #include<vector> #include<set> #include<map> #include<queue> #include<numeric> #include<functional> #include<algorithm> #include<bitset> using namespace std; #define INF (1<<29) #define rep(i,n) for(int i=0;i<(int)(n);i++) #define all(v) v.begin(),v.end() #define uniq(v) v.erase(unique(all(v)),v.end()) #define indexOf(v,x) (find(all(v),x)-v.begin()) int solve1(){ int t=0,res; while(1){ cout<<"? "<<0<<endl; cin>>res; if(res==0)return t; t++; } } int solve2(){ int lb=50,ub=1000000000+1,t=0; while(1){ int mid=(lb+ub)/2; cout<<"? "<<mid<<endl; int res; cin>>res; if(res==-1){ ub=mid; }else if(res==0){ return max(0,mid+t); }else{ lb=mid+1; } t++; lb--; ub--; } } int main(){ int res; cout<<"? 50"<<endl; cin>>res; if(res==0)cout<<"! "<<50<<endl; else if(res==-1)cout<<"! "<<solve1()+1<<endl; else cout<<"! "<<solve2()+1<<endl; return 0; }