結果
問題 | No.1830 Balanced Majority |
ユーザー |
![]() |
提出日時 | 2022-02-04 21:58:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 585 bytes |
コンパイル時間 | 440 ms |
コンパイル使用メモリ | 64,000 KB |
実行使用メモリ | 38,160 KB |
平均クエリ数 | 0.23 |
最終ジャッジ日時 | 2024-06-11 11:49:35 |
合計ジャッジ時間 | 3,994 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 1 |
other | AC * 2 TLE * 1 -- * 22 |
ソースコード
#include <iostream> using namespace std; int main() { int n; cin >> n; int s0, s1; cout << "? " << 1 << endl; cin >> s0; cout << "? " << n - 1 << endl; cin >> s1; if(s0 != n / 2 - s1){ cout << "! " << 2 << " " << n - 1 << endl; return 0; } int right = n, left = 0; bool f = s0; while(right - left > 1){ int mid = (right + left) / 2; int s; cin >> s; if(s * 2 == mid){ if(mid * 2 > n) cout << "! " << 1 << " " << mid << endl; else cout << "! " << mid + 1 << " " << n << endl; return 0; } if((s * 2 > mid) == f) left = mid; else right = mid; } }