NC223807. TheBoomsdayProject
描述
输入描述
The first line of input contains three integers , denoting the number of discount card types, the number of rental records, and the price of a single rent.
Then follow lines, specifying the types of discount cards. The th line contains three integers , denoting the valid period, the number of free rents, and the price of a discount card of type .
The last lines describe Aloha's rental records. The th of them contains two integers , representing that Aloha would rent bikes times on Day . It is guaranteed that are distinct.
输出描述
Print one integer in a line, denoting the minimum money Aloha has to pay if he adopts the best strategy.
示例1
输入:
2 1 10 1 3 12 1 2 9 1 10
输出:
42
示例2
输入:
2 4 10 1 3 12 1 2 9 1 3 2 3 3 3 4 1
输出:
45
C++(clang++ 11.0.1) 解法, 执行用时: 635ms, 内存消耗: 2856K, 提交时间: 2022-11-03 09:32:42
#include<bits/stdc++.h> using namespace std; int n,m,r,f[300005],a[300005]; int l[505],d[505],k[505],c[505]; signed main() { ios::sync_with_stdio(0); cin>>n>>m>>r; for(int i=1;i<=n;i++) cin>>d[i]>>k[i]>>c[i],l[i]=1; int len=0; for(int i=1,p,q;i<=m;i++) { cin>>p>>q; while(q--) a[++len]=p; } sort(a+1,a+len+1); for(int i=1;i<=len;i++) { f[i]=f[i-1]+r; for(int j=1;j<=n;j++) { while(i-l[j]+1>k[j]||a[i]-a[l[j]]+1>d[j]) { l[j]++; if(l[j]>i)break; } f[i]=min(f[i],f[l[j]-1]+c[j]); } //cerr<<f[i]<<endl; } cout<<f[len]<<endl; }