CSU1578: Opening Ceremony

Description

CSU1578: Opening Ceremony_第1张图片

Input

Output

Sample Input

6
2 1 8 8 2 3

Sample Output

5

HINT

Source

NCPC 2014


题意:又是一道理解了很久的题,英语弱菜没办法,意思就是,每次除掉一列或者一行,要几部可以移完

#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
#define ls 2*i
#define rs 2*i+1
#define up(i,x,y) for(i=x;i<=y;i++)
#define down(i,x,y) for(i=x;i>=y;i--)
#define mem(a,x) memset(a,x,sizeof(a))
#define w(a) while(a)
#define LL long long
const double pi = acos(-1.0);
#define Len 200005
#define mod 360000
const int INF = 0x3f3f3f3f;
#define exp 1e-6

int a[100005];
int main()
{
    int n,i;
    w(scanf("%d",&n)!=EOF)
    {
        up(i,1,n)
            scanf("%d",&a[i]);
        sort(a+1,a+n+1);
        int mmin=n;
        up(i,1,n)
        {
            mmin=min(mmin,(n-i+a[i]));
        }
        printf("%d\n",mmin);
    }
    return 0;
}


你可能感兴趣的:(CSU)