标签:tor png color cto begin get cstring fine https
#include <iostream> #include <vector> #include <algorithm> #include <queue> #include <cstring> #include <set> #include <unordered_map> #include <cmath> # define LL long long using namespace std; int N; vector<int> dis; int find(int n){ //找第一个比n大的数 int left=0; int right=N-1; while(left<=right){ int mid=(left+right)/2; if(dis[mid]>n){ right=mid-1; }else{ left=mid+1; } } if(left>N-1) return 0; return N-left; } int main(){ scanf("%d", &N); for(int i=0;i<N;i++){ int a; scanf("%d", &a); dis.push_back(a); } sort(dis.begin(), dis.end()); int left=0; int right=N; while(left<=right){ int mid=(left+right)/2; int nums=find(mid); //最大的满足nums==mid if(nums==mid){ left=mid+1; }else if(nums<mid){ right=mid-1; }else { left=mid+1; } } printf("%d\n", right); return 0; }
标签:tor png color cto begin get cstring fine https
原文地址:https://www.cnblogs.com/FEIIEF/p/12474030.html