#include<iostream>//动态规划
using namespace std;
#define INF 0x3f3f3f3f
int main()
{int L1, L2, L3, C1, C2, C3;//cin >> L1 >> L2 >> L3 >> C1 >> C2 >> C3;scanf("%d%d%d%d%d%d", &L1, &L2, &L3, &C1, &C2, &C3);int N;cin >> N;int a, b;cin >> a;cin >> b;if (a > b) {int temp = a;a = b;b = temp;}int sta[10000];int dp[10000];for (int i = 2; i < N + 1; i++) {cin >> sta[i];}for (int i = a; i < b + 1; i++) {dp[i] = INF;}dp[a] = 0;for (int i = a; i < b; i++) {for (int j = i + 1; j < b + 1; j++) {if (sta[j] - sta[i] <= L1&&dp[j] > dp[i] + C1) {dp[j] = dp[i] + C1;}if (sta[j] - sta[i] <= L2&&dp[j] > dp[i] + C2) {dp[j] = dp[i] + C2;}if (sta[j] - sta[i] <= L3&&dp[j] > dp[i] + C3) {dp[j] = dp[i] + C3;}}}cout << dp[b] << endl;return 0;
}
详细解决方案
百练OJ-Railway tickets
热度:96 发布时间:2023-09-18 19:06:24.0
相关解决方案
- [急]这个页面http://www.sh-tickets.com/顶部的日历带参数是如何得到的?
- (49)I had the lucky to get tickets, and I'll hit the road this saturday^该怎么处理
- (49)I had the lucky to get tickets, and I'll hit the road this saturday^解决办法
- {}这个方法j为什么会打印出(线程名+sell tickets:0)来
- (49)I had the lucky to get tickets, and I'll hit the road this saturday^解决方法
- 百练OJ-Railway tickets
- 10-----Forecast of China Railway Freight Volume by Random Forest Regression Model
- T3 Railway Trip
- (复习次数:1)HDU 1260 Tickets【线性dp】
- Buy Tickets (线段树)
- SGU 390 Tickets(数位dp,较难)
- URAL 1036 Lucky Tickets(基础dp)
- codeforces 962B. Students in Railway Carriage
- POJ 2828 Buy Tickets(算法竞赛进阶指南, 树状数组,二分)
- POJ 1818——Buy Tickets【线段树 单点更新】
- HDU 1260 - Tickets
- 【POJ2828】Buy Tickets
- poj 2828 Buy Tickets(线段树中单点更新较难的题目)
- HDU3394 Railway(点双连通分量)
- Poj2828 Buy Tickets(逆序思维+线段树)
- [kuangbin带你飞]专题十二 基础DP1 H - Tickets HDU - 1260