The meaning of problems
https://vjudge.net/problem/CodeForces-1007A
Rearrangement of a sequence, such that the new position of the maximum number than the number corresponding to a large number of the original.
Thinking
For chestnuts, such as 122,333,345, then for a number, certainly bigger than he used to cover his smallest to the larger number have more chance to be covered behind this. 1 with the cover 2 such as, but not with a cover 5, because then 4 will not be covered. Consider scrambled, such as 213533432, the same, with a cover 2, a cover 3 2, and in fact no different ordered sequence, we take a direct sequence, double pointer traversal can be.
Code
#include<bits/stdc++.h> using namespace std; #define inf 0x3f3f3f3f #define ll long long const int N=200005; const int mod=1e9+7; const double eps=1e-8; const double PI = acos(-1.0); #define lowbit(x) (x&(-x)) int a[N]; int main() { std::ios::sync_with_stdio(false); int n; cin>>n; for(int i=1;i<=n;i++) cin>>a[i]; sort(a+1,a+1+n); int i=1,j=1; for(;i<=n;i++) { if(a[i]>a[j]) { j++; } } cout<<j-1<<endl; return 0; }