Codeforces Round #497 (Div. 2) C. Reorder the Array

Bryce1010模板

http://codeforces.com/contest/1008/problems

#include <bits/stdc++.h>

using namespace std;
#define ll long long

const int MAXN=1e5+10;
const int INF=0x3f3f3f3f;

int a[MAXN];



int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a+1,a+1+n);
    int j=1,cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(a[i]>a[j])
        {
            cnt++;
            j++;
        }

    }
    cout<<cnt<<endl;

    //cout << "Hello world!" << endl;
    return 0;
}

原文地址:https://www.cnblogs.com/bryce1010/p/9386844.html