結果
| 問題 | No.253 ロウソクの長さ |
| コンテスト | |
| ユーザー |
sr_tsubaki
|
| 提出日時 | 2020-01-31 10:38:47 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 743 bytes |
| 記録 | |
| コンパイル時間 | 1,566 ms |
| コンパイル使用メモリ | 167,628 KB |
| 実行使用メモリ | 25,220 KB |
| 平均クエリ数 | 21.33 |
| 最終ジャッジ日時 | 2024-07-17 02:27:55 |
| 合計ジャッジ時間 | 4,570 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 36 |
コンパイルメッセージ
main.cpp: In function 'int Main()':
main.cpp:38:1: warning: control reaches end of non-void function [-Wreturn-type]
38 | }
| ^
ソースコード
#include <bits/stdc++.h>
#define rep(i, k) for (int i = 0; i < k; i++)
#define pair(x, y) make_pair((x), (y))
using namespace std;
int MAX = 1000000000;
int Q = 0;
int ask(int Y){
cout << "? " << (Y-Q) << endl;
Q++;
int res;
cin >> res;
return res;
}
int search(int low,int high){
int mid,res;
while(true){
mid = (low +high)/2;
res = ask(mid);
if (res == 0){
return mid;
}else if(res ==1){
low = mid+1;
}else{
high = mid-1;
}
}
}
int Main(){
int s = ask(100);
if(s == 1) return search(101,MAX);
if(s == 0) return 100;
if(s == -1) return search(10,99);
}
int main(){
int res = Main();
cout << "! " << res << endl;
}
sr_tsubaki