| Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
|---|---|---|---|---|---|---|---|---|---|
| 108870 | 林扬泉 | 均分纸牌 | C++ | Accepted | 100 | 0 MS | 248 KB | 455 | 2023-11-04 11:22:33 |
#include<bits/stdc++.h> using namespace std; int n,sum,step,i,j; int x[110]; int main(){ cin>>n; for(i=1;i<=n;i++){ cin>>x[i]; sum+=x[i]; } sum/=n; for(i=1;i<=n;i++){ x[i]-=sum;//sum=10 (9 8 17 6)->(-1 -2 7 -4) } i=1,j=n; while(x[i]==0&&i<n){ i++; } while(x[j]==0&&j>1){ j--; } while(i<j){ x[i+1]+=x[i]; x[i]=0; step++; i++; while(x[i]==0&&i<j){ i++; } } cout<<step; return 0; }