标签:std multi put color col hid log pac return
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; int n,a[1000010],cnt; int main(){ freopen("multiset.in","r",stdin);freopen("multiset.out","w",stdout); // freopen("Cola.txt","r",stdin); scanf("%d",&n); for(int i=1;i<=n;i++)scanf("%d",&a[i]); if(n==1&&a[1]==0){ puts("0"); return 0; } int ans=0; sort(a+1,a+n+1); int q=1; for(int i=1;i<=n;i++){ if(a[i]!=0){q=i;break;} cnt++; } while(1){ if(q>n)break; ans++;cnt=cnt/2+cnt%2; for(int i=q;i<=n;i++)a[i]-=1; // for(int i=1;i<=n;i++)cout<<a[i]<<‘ ‘; while(a[q]==0&&q<=n)cnt++,q++; } while(cnt>1){ ans++; cnt=cnt/2+cnt%2; } printf("%d",ans); }
标签:std multi put color col hid log pac return
原文地址:http://www.cnblogs.com/thmyl/p/7760073.html