日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國(guó)內(nèi)最全I(xiàn)T社區(qū)平臺(tái) 聯(lián)系我們 | 收藏本站
阿里云優(yōu)惠2
您當(dāng)前位置:首頁(yè) > php開(kāi)源 > php教程 > POJ2355――Railway tickets

POJ2355――Railway tickets

來(lái)源:程序員人生   發(fā)布時(shí)間:2014-12-23 08:53:46 閱讀次數(shù):3530次
Railway tickets
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 2710   Accepted: 962

Description

The railway line "Ekaterinburg-Sverdlovsk" with several stations has been built. This railway line can be represented as a line segment, railway stations being points on it. The railway line starts at the station "Ekaterinburg" and finishes at the station "Sverdlovsk", so stations are numbered starting from "Ekaterinburg" (it has number 1) and "Sverdlovsk" is the last station.

Cost of the ticket between any two stations depends only on a distance between them. The prices for the tickets are specified in the following table.

distance between stations -X

price for the ticket

0<X<=L1

C1

L1<X<=L2

C2

L2<X<=L3

C3


Direct tickets from one station to another can be booked if and only if the distance between these station does not exceed L3. So sometimes it is necessary to book several tickets to pay for the parts of the whole way between stations.

For example, on the railway line shown at the figure above there are seven stations. The direct ticket from the second station to the sixth one can not be booked. There are several ways to pay for the travel between these stations. One of them is to book two tickets: one ticket at price C2 to travel between the second and the third stations, and other at price C3 to travel between the third and the sixth stations. Note, that though the distance between the second and the sixth stations is equal to 2*L2, the whole travel can not be paid by booking two tickets at price C2, because each ticket is valid for only one travel and each travel should start and end only at stations.

Your task is to write a program, that will find the minimal cost of the travel between two given stations.

Input

The first line of the input file contains 6 integers L1, L2, L3, C1, C2, C3 (1 <= L1 < L2 < L3 <= 10^9, 1 <= C1 < C2 < C3 <= 10^9) in the specified order with one space between. The second line contains the amount of stations N (2 <= N <= 10000). The third line contains two different integers separated by space. They represent serial numbers of stations, the travel between which must be paid. Next N⑴ lines contain distances from the first station ("Ekaterinburg") on the railway line to others. These distances are given as different positive integers and are arranged in the ascending order. The distance from "Ekaterinburg" to "Sverdlovsk" does not exceed 10^9. The distance between any neighboring stations does not exceed L3. The minimal travel cost between two given stations will not exceed 10^9.

Output

Program should print to the output file the only number, which is the minimal travel cost between two given stations.

Sample Input

3 6 8 20 30 40 7 2 6 3 7 8 13 15 23

Sample Output

70

Source

Ural Collegiate Programming Contest 1999

水dp,1開(kāi)始還想著用線段樹(shù)去優(yōu)化,結(jié)果暴力就過(guò)了

#include <map> #include <set> #include <list> #include <queue> #include <stack> #include <vector> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <algorithm> using namespace std; const int inf = 0x3f3f3f3f; const int N = 10010; int dp[N]; int sta[N]; int main() { int l1, l2, l3; int c1, c2, c3; int n, s, e; while(~scanf("%d%d%d%d%d%d", &l1, &l2, &l3, &c1, &c2, &c3)) { // printf("%I64d ", inf); scanf("%d", &n); scanf("%d%d", &s, &e); if (s > e) { swap(s, e); } memset (dp, inf, sizeof(dp)); sta[1] = 0; dp[e] = 0; for (int i = 2; i <= n ; ++i) { scanf("%d", &sta[i]); } for (int i = e - 1; i >= s; --i) { for (int j = i; j <= e; ++j) { if (sta[j] - sta[i] > l3) { break; } if (sta[j] - sta[i] <= l1) { dp[i] = min(dp[i], dp[j] + c1); } else if (sta[j] - sta[i] <= l2) { dp[i] = min(dp[i], dp[j] + c2); } else { dp[i] = min(dp[i], dp[j] + c3); } } } printf("%d ", dp[s]); } return 0; }


生活不易,碼農(nóng)辛苦
如果您覺(jué)得本網(wǎng)站對(duì)您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈(zèng)
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關(guān)閉
程序員人生
主站蜘蛛池模板: 欧美日韩免费一区二区三区 | 欧美精品一级二级 | 欧美一区二区三区免费观看 | 成人黄色在线观看 | 韩国免费a级毛片 | 国产成人精品免费视频 | 国产一区二区精彩视频 | av免费网站在线观看 | 精品久久久久久综合日本 | 99精品视频在线观看视频 | 国产三级在线 | 国产不卡免费视频 | 国产伦精品一区二区 | 91久久| 欧美a级成人淫片免费看 | 国产精品国产三级国产aⅴ中文 | 99男女国产精品免费视频 | 91精品入口蜜桃 | 5999在线视频免费观看 | 成人一区二区三区 | 久久久国产精品 | 精品在线一区二区三区 | 天堂网avav | 91亚洲国产成人久久精品网站 | 在线观看精品一区 | 高清成人av | 精品国产一区二区三区日日嗨 | 欧美久久久久久 | 国产精品视频一二三区 | 久久99网| 在线观看精品 | 日韩精品一区二区三区在线播放 | 澳门永久av免费网站 | 性疯狂做受xxxx高清视频 | 亚州精品天堂中文字幕 | 欧美在线视频一区 | 亚洲黄视频 | 成人在线免费看 | 久久久久黄色 | 国产尤物一区 | 亚洲视频观看 |