编程介的小学生 2017-10-30 09:19 采纳率: 20.5%
浏览 859
已采纳

Ingress

Problem Description
Brickgao, who profited from your accurate calculating last year, made a great deal of money by moving bricks. Now he became ``gay shy fool'' again and recently he bought an iphone and was deeply addicted into a cellphone game called Ingress. Now he is faced with a problem so he turns to you for help again. We make some slight modifications based on the original rules, so please draw attention to the details below.

There are N portals (indexed from 1 to N) around Brickgao's home, and he can get some substances called XM by hacking the portals. It's known that for each portal i, he can get Ai XM during the first hack, and after each hack, the amount of XM he will get during the next hack will decrease by Bi. If the amount of XM he can get is less than or equal to zero, Brickgao can't get XM from that portal anymore. For the i-th portal, if Ai=10,Bi=2 and he hacks 3 times, he will get 10, 8, 6 XM during each hack.

There are M bidirectional roads between some pairs of portals and between Brickgao's home and some portals. Now he is eager to start his Ingress journey from home and finally return home, but due to the extremely hot weather, Brickgao will feel sick when you hack more than K times or the distance he covers is more than L. So how much XM he can get at most during this journey?

Input
The first line contains a single integer T(T≤20), indicating the number of test cases.

The first line of each case are four integers N(1≤N≤16),M(0≤M≤N(N+1)2),K(1≤K≤50) and L(2≤L≤2000).
The second line of each case contains N non-negative integers where the i-th denotes Ai(Ai≤500).
The third line of each case contains N non-negative integers where the i-th denotes Bi(Bi≤50).
Each of next M line contains 3 non-negative integers u,v(0≤u,v≤n) and c(0≤c≤1000) , denotes that there is a road with the length of c between the u-th and the v-th portal. If u or v equals to 0, it means Brickgao's home.

Output
For each test case, output the case number first, then the amount of maximum XM Brickgao can get.

Sample Input
2
1 1 3 2
5
3
0 1 1
3 6 3 5
10 7 5
2 3 1
0 1 3
0 2 1
0 3 1
1 2 2
2 3 3
1 3 4

Sample Output
Case 1: 7
Case 2: 16

  • 写回答

1条回答

  • threenewbee 2017-11-21 15:52
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据