官方题解——无敌阿姨
无敌阿姨
http://www.nowcoder.com/questionTerminal/062583671a3044c5bf2a29754e74eda5
按照题意模拟即可,看不懂就是出题人语文没学好。
附队友代码:
#include <bits/stdc++.h> #include <cstring> #define MAXN 103 using namespace std; int a[MAXN]; int main() { int T; scanf("%d",&T); while(T--) { int n,m,k; int sum = 0; scanf("%d%d%d",&n,&m,&k); for(int i = 1;i <= n;i++) { scanf("%d",&a[i]); sum += a[i]; } int ans = 0,res; int now = 0; while(now < sum) { ans++; res = m; for(int i = 1;i <= n;i++) if(a[i]) { while(a[i] && res) { a[i]--; res--; now++; } if(res <= k) break; res -= k; } //printf("%d\n",now); } printf("%d\n",ans); } }