| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 46399 | 杨中琦 | 均分纸牌 | C++ | Accepted | 100 | 0 MS | 256 KB | 371 | 2022-07-13 13:00:56 |
#include<bits/stdc++.h> using namespace std; int main(){ int n,ave,step,a[100000],i,j; cin>>n; ave=0;step=0; for (i=1;i<=n;++i){ cin>>a[i]; ave+=a[i]; } ave/=n; for (i=1;i<=n;++i) a[i]-=ave; i=1;j=n; while (a[i]==0&&i<n) ++i; while (a[j]==0&&j>1) --j; while (i<j){ a[i+1]+=a[i]; a[i]=0; ++step; ++i; while (a[i]==0&&i<j) ++i; } cout<<step<<endl; }