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;
}

posted @ 2018-07-24 10:50  Bryce1010  阅读(67)  评论(0编辑  收藏  举报