結果
問題 | No.1830 Balanced Majority |
ユーザー | 沙耶花 |
提出日時 | 2022-02-04 21:45:15 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 700 bytes |
コンパイル時間 | 4,325 ms |
コンパイル使用メモリ | 260,044 KB |
実行使用メモリ | 24,384 KB |
平均クエリ数 | 13.85 |
最終ジャッジ日時 | 2023-09-02 04:40:35 |
合計ジャッジ時間 | 6,294 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 28 ms
24,012 KB |
testcase_01 | AC | 24 ms
23,412 KB |
testcase_02 | AC | 23 ms
23,952 KB |
testcase_03 | AC | 23 ms
23,940 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 24 ms
23,424 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 27 ms
23,568 KB |
testcase_16 | AC | 26 ms
23,952 KB |
testcase_17 | AC | 26 ms
23,964 KB |
testcase_18 | AC | 26 ms
24,324 KB |
testcase_19 | AC | 24 ms
23,640 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 24 ms
24,048 KB |
ソースコード
#include <stdio.h> #include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) #define Inf 1000000001 void answer(int n){ cout<<"! 1 "<<n<<endl; exit(0); } int query(int N){ cout<<"? "<<N<<endl; int ret; cin>>ret; if(ret*2 == N){ answer(N); } return ret; } int main(){ int N; cin>>N; int sum = query(N-1); int ok = N-1; int ng = 0; while(ok-ng>1){ int mid = (ok+ng)/2; int ret= query(mid); if(sum!=N/2){ if(N/2 != mid-ret)ng = mid; else ok = mid; } else{ if(N/2 != ret)ng = mid; else ok = mid; } } cout<<"! "<<ok<<' '<<ok+1<<endl; return 0; }