题意:租共享单车,每次r元,可以买卡,卡的有效期为d天,可用次数为k次,费用为c元,每次买新卡会覆盖旧卡,现有n种买卡的方案,m天需要骑车,其中这m天,第pi天需要骑车qi次。问最小费用。
题解:关于第i天可能使用的骑车方案不是同一种,所以,干脆不要看每一天用哪一种方案了,而是每一次骑车用哪种方案。
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115#include <algorithm> #include <deque> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <string> #include <unordered_map> #include <vector> #define ll long long #define ms(a, b) memset(a, b, sizeof(a)) #define lowbit(x) (x & -x) #define fi first #define se second #define Size(a) int((a).size()) #define all(x) x.begin(), x.end() #define ull unsigned long long #define lson (rt << 1) #define rson (rt << 1 | 1) #define endl "n" #define bug cout << "----acac----" << endl; #define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); using namespace std; ll ksm(ll a, ll b, ll mod) { ll ans = 1; while (b) { if (b & 1) { ans = (a % mod * ans % mod) % mod; } b >>= 1; a = (a % mod * a % mod) % mod; } return ans; } ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } ll read() { ll x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } const ll mod = 998244353; const int maxn = 2e6 + 10; const int N = 2e5 + 10; const int maxm = 5e3 + 50; const double eps = 1e-8; const ll inf = 0x3f3f3f3f; const ll lnf = 0x3f3f3f3f3f3f3f3f; const double pi = acos(-1); int n, m, r; map<int, int> p; struct node { int d, k, c; } a[maxn]; int v[maxn]; ll dp[maxn]; int pre[maxn];//表示第i种方案最后一次使用时在第几次骑车 int main() { IOS; cin >> n >> m >> r; for (int i = 1; i <= n;i++) { pre[i] = 1; cin >> a[i].d >> a[i].k >> a[i].c; } int cnt = 0; for (int i = 1; i <= m;i++) { int x, y; cin >> x >> y; while(y--) { v[++cnt] = x;//第i次骑车是第几天 } } sort(v + 1, v + 1 + cnt); for (int i = 1; i <= cnt ;i++) { dp[i] = dp[i-1]+r; for (int j = 1; j <= n;j++) { while(v[pre[j]]+a[j].d<=v[i]||a[j].k+pre[j]<=i) pre[j]++; dp[i] = min(dp[i], dp[pre[j] - 1] + a[j].c); } } cout << dp[cnt] << endl; return 0; }
最后
以上就是义气小虾米最近收集整理的关于H. The Boomsday Project的全部内容,更多相关H.内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复