結果
| 問題 |
No.253 ロウソクの長さ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-02 20:28:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 2,000 ms |
| コード長 | 444 bytes |
| コンパイル時間 | 580 ms |
| コンパイル使用メモリ | 64,664 KB |
| 実行使用メモリ | 25,452 KB |
| 平均クエリ数 | 31.31 |
| 最終ジャッジ日時 | 2024-07-17 02:35:03 |
| 合計ジャッジ時間 | 3,489 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 36 |
コンパイルメッセージ
main.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
10 | main()
| ^~~~
ソースコード
#include<iostream>
using namespace std;
int ask(int Y)
{
cout<<"? "<<Y<<endl;
int ret;
cin>>ret;
return ret;
}
main()
{
int fst=ask(100);
int ans;
if(fst==0)
{
ans=100;
}
else if(fst<0)
{
int tm=1;
for(;;)
{
if(ask(9)==0)break;
tm++;
}
ans=tm+9;
}
else
{
int L=100,R=1e9+1;
int tm=1;
while(R-L>1)
{
int M=(L+R)/2;
if(ask(M-tm)<0)R=M;
else L=M;
tm++;
}
ans=L;
}
cout<<"! "<<ans<<endl;
}