• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
HaibaraAi
博客园    首页    新随笔    联系   管理    订阅  订阅

LA 5422 Gone Fishing

 

  Gone Fishing 

妈蛋,这题左改又改,输出格式是这么个玩意- -!,还有就是,取最大个数优先的没弄好! 

John is going on a fishing trip. He has h hours available ( $1 \leŸ h \leŸ 16$), and there are n lakes in the area ( $2 \leŸ n \leŸ 25$) all reachable along a single, one-way road. John starts at lake 1, but he can finish at any lake he wants. He can only travel from one lake to the next one, but he does not have to stop at any lake unless he wishes to. For each  $i = 1, \dots, n- 1$, the number of 5-minute intervals it takes to travel fr$1 \leŸ h \leŸ 16$om lake i to lake i + 1 is denoted ti ( $0 < t_i \leŸ 192$). For example, t3 = 4 means that it takes 20 minutes to travel from lake 3 to lake 4.

To help plan his fishing trip, John has gathered some information about the lakes. For each lake i, the number of fish expected to be caught in the initial 5 minutes, denoted fi ( $f_i \ge– 0$), is known. Each 5 minutes of fishing decreases the number of fish expected to be caught in the next 5-minute interval by a constant rate of di ( $d_i \ge– 0$). If the number of fish expected to be caught in an interval is less than or equal to di, there will be no more fish left in the lake in the next interval. To simplify the planning, John assumes that no one else will be fishing at the lakes to affect the number of fish he expects to catch.

Write a program to help John plan his fishing trip to maximize the number of fish expected to be caught. The number of minutes spent at each lake must be a multiple of 5.

Input 

You will be given a number of cases in the input. Each case starts with a line containing n. This is followed by a line containing h. Next, there is a line of n integers specifying fi ( $1 \leŸ i \leŸ n$), then a line of n integers di ( $1 \leŸ i \leŸ n$), and finally, a line of n - 1 integers ti ( $1 \leŸ i Ÿ\le n - 1$). Input is terminated by a case in which n = 0.

Output 

For each test case, print the number of minutes spent at each lake, separated by commas, for the plan achieving the maximum number of fish expected to be caught (you should print the entire plan on one line even if it exceeds 80 characters). This is followed by a line containing the number of fish expected. If multiple plans exist, choose the one that spends as long as possible at lake 1, even if no fish are expected to be caught in some intervals. If there is still a tie, choose the one that spends as long as possible at lake 2, and so on. Insert a blank line between cases.

Sample Input 

2
1
10 1
2 5
2
4
4
10 15 20 17
0 3 4 3
1 2 3
4
4
10 15 50 30
0 3 4 3
1 2 3
0

Sample Output 

45, 5
Number of fish expected: 31

240, 0, 0, 0
Number of fish expected: 480

115, 10, 50, 35
Number of fish expected: 724

Miguel A. Revilla 2000-02-09
 1 #pragma comment(linker,"/STACK:102400000,102400000")
 2 #include <cstdio>
 3 #include <vector>
 4 #include <cmath>
 5 #include <queue>
 6 #include <cstring>
 7 #include <iostream>
 8 #include <algorithm>
 9 using namespace std;
10 #define INF 0x7fffffff
11 #define mod 1000000007
12 #define ll long long
13 #define maxn 105
14 #define pi acos(-1.0)
15 //const int maxk = 10 + 1, inf = ~0U >> 2;
16 int vis[maxn];
17 int n, m, ans;
18 int a[maxn], b[maxn], t[maxn], x[maxn],fish[maxn];
19 void solve(){
20     for (int i = 0; i < n; i++){
21         m -= t[i];
22         int res = 0;
23         int tmp[maxn] = { 0 };
24         for (int j = 0; j <= i; j++)fish[j] = a[j];
25         for (int j = 0; j < m; j++){
26             int p = 0;
27             for (int k = 0; k <= i; k++)
28             if (fish[p] < fish[k])p = k;
29             if (fish[p] <= 0)break;
30             res += fish[p];
31             fish[p] -= b[p];
32             tmp[p] += 5;
33         }
34         if (ans < res){
35             ans = res;
36             int num = 0;
37             for (int j = 0; j <= i; j++){
38                 x[j] = tmp[j];
39                 num += tmp[j];
40             }
41             x[0] += m * 5 - num;
42         }
43     }
44 }
45 int main(){
46     int cas = 1;
47     while (scanf("%d", &n) && n){
48         if (cas != 1)printf("\n");
49         scanf("%d", &m); m *= 12;
50         for (int i = 0; i < n; i++)scanf("%d", &a[i]);
51         for (int i = 0; i < n; i++)scanf("%d", &b[i]);
52         for (int i = 1; i < n; i++)scanf("%d", &t[i]);
53         memset(x, 0, sizeof x);
54         t[0] = 0;ans = -1;
55         solve();
56         for (int i = 0; i < n; i++)printf(i == n-1 ? "%d\n" : "%d, ", x[i]);
57         printf("Number of fish expected: %d\n",ans);
58         cas = 2;
59     }
60     return 0;
61 }
View Code

 

posted @ 2013-12-26 12:19  HaibaraAi  阅读(110)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3