結果

問題 No.253 ロウソクの長さ
ユーザー nasadigitalnasadigital
提出日時 2015-07-24 23:14:25
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 748 bytes
コンパイル時間 533 ms
コンパイル使用メモリ 64,796 KB
実行使用メモリ 24,468 KB
平均クエリ数 21.11
最終ジャッジ日時 2023-09-23 20:59:31
合計ジャッジ時間 3,385 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
23,568 KB
testcase_01 AC 25 ms
23,676 KB
testcase_02 AC 25 ms
24,240 KB
testcase_03 AC 25 ms
24,348 KB
testcase_04 AC 26 ms
23,424 KB
testcase_05 AC 25 ms
24,300 KB
testcase_06 AC 26 ms
23,568 KB
testcase_07 AC 25 ms
24,288 KB
testcase_08 AC 25 ms
24,036 KB
testcase_09 AC 25 ms
24,300 KB
testcase_10 AC 26 ms
23,664 KB
testcase_11 AC 25 ms
23,460 KB
testcase_12 AC 25 ms
24,276 KB
testcase_13 AC 26 ms
24,276 KB
testcase_14 AC 25 ms
23,844 KB
testcase_15 AC 25 ms
24,372 KB
testcase_16 AC 24 ms
24,036 KB
testcase_17 AC 24 ms
24,048 KB
testcase_18 AC 24 ms
23,568 KB
testcase_19 AC 25 ms
23,592 KB
testcase_20 AC 26 ms
24,300 KB
testcase_21 AC 25 ms
23,580 KB
testcase_22 AC 24 ms
23,676 KB
testcase_23 AC 25 ms
24,036 KB
testcase_24 AC 24 ms
24,264 KB
testcase_25 AC 26 ms
23,856 KB
testcase_26 AC 25 ms
23,652 KB
testcase_27 AC 25 ms
24,276 KB
testcase_28 AC 25 ms
24,312 KB
testcase_29 AC 25 ms
23,664 KB
testcase_30 AC 26 ms
24,048 KB
testcase_31 AC 25 ms
23,652 KB
testcase_32 AC 26 ms
23,844 KB
testcase_33 AC 25 ms
24,468 KB
testcase_34 AC 24 ms
24,264 KB
testcase_35 AC 26 ms
23,424 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:54:13: warning: ‘rez’ may be used uninitialized in this function [-Wmaybe-uninitialized]
 cout<<"! "<<rez<<endl;
             ^~~

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <cmath>
#include <utility>
#include <algorithm>
#include <vector>
#include <cstring>

#define _P(x) printf(x);
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;



int main(){

int sec=0;
int l=10,r=1e9;
int rez;
int a;
cout<<"? 101"<<endl;
cin>>a;
if(a==-1)
r=100;
else if(a==0){
	cout<<"! "<<101<<endl;
	return 0;
}
else l=102;
sec++;
while(l<=r){
int mid=(l+r)/2-sec;
cout<<"? "<<mid<<endl;
cin>>a;
if(a==0){
rez=mid+sec;
break;
}
if(a==1){
l=mid+sec+1;
rez=mid+sec;	
}
if(a==-1)
r=mid+sec-1;
sec++;
}
cout<<"! "<<rez<<endl;
return 0;
}
0