Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:Notice~数据好弱啊~看书才知道贪心~唉~菜鸟一只~#include<iostream> #include<algorithm> using namespace std; int main() { int h, n, fi[26], time, ti[26], di[26], last[26], lasttime[26], value[26], maxf; while (cin>>n && n) { cin>>h; maxf = -2; for (int i = 1; i <= n; i++) cin>>fi[i]; for (int i = 1; i <= n; i++) cin>>di[i]; for (int i = 1; i <= n - 1; i++) cin>>ti[i]; for (int i = 1; i <= n; i++) { memset(value, 0, sizeof(value)); time = h * 60 / 5; int sumt = 0, sum = 0, num[26]; for (int k = 1; k <= n; k++) num[k] = fi[k]; for (int j = 1; j < i; j++) sumt += ti[j]; time -= sumt; if (time <= 0)break; while (time > 0) { int temp, max = -1; for (int l = 1; l <= i; l++) if (max < num[l]) { max = num[l]; temp = l; } sum += num[temp]; if (num[temp] >= di[temp])num[temp] -= di[temp]; else num[temp] = 0; time -= 1; value[temp] += 1; } if (maxf < sum) { maxf = sum; for (int g = 1; g <= n; g++) last[g] = num[g]; for (int g = 1; g <= n; g++) lasttime[g] = value[g] * 5; } } for (int g = 1; g <= n; g++) { if (g > 1)printf(", "); printf("%d", lasttime[g]); } cout<<endl; printf("Number of fish expected: %d\n\n", maxf); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator