--- title: "小蓝与捉迷藏" created: 2025-11-28 tags: - 算法 --- # 小蓝与捉迷藏 ## 题目 [小蓝与捉迷藏](https://dashoj.com/d/lqbG1/p/6) ![[image-f0b12881.png]] ## 思路分析 ![[image-9aa48966.png]] ## 代码实现 ```cpp #include using namespace std; #define endl '\n' #define int long long const int N=1e5+10; int a[N]; int n; bool check(int x){ int sum=0;//计算所有人可以当捕手的次数 for(int i=0;i=x)//玩x轮需要x个捕手 return true; return false; } signed main() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); cin>>n; int maxv=0; for(int i=0;i>a[i]; maxv = max(maxv, a[i]); } int l=maxv,r=2e9; while(l>1; if(check(mid)) r=mid; else l=mid+1; } cout<