1 E - Opening Ceremony
https://vjudge.net/contest/647025#problem/E
当时想的太复杂没想到消掉最下面一层最优,因为相对层数不变。
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[100005];
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i=1;i<=n;i++)
scanf("%d",&a[i]);
sort(a+1,a+n+1);
int mmin=n;
for(int i=1;i<=n;i++)
{
mmin=min(mmin,(n-i+a[i]));//i+1之后消列,i前除行。
}
printf("%d\n",mmin);
}
return 0;
}
标签:练习题,Ceremony,int,VJ,消掉,include
From: https://www.cnblogs.com/hoshino-/p/18358155