leetcode 6011. 完成比赛的最少时间(需要转换的dp)

 1 class Solution {
 2 public:
 3     typedef long long ll;
 4     int minimumFinishTime(vector<vector<int>>& tires, int changeTime, int numLaps) {
 5        ll  miuse[1005],dp[1005];
 6        memset(dp,0x3f,sizeof(dp));
 7        memset(miuse,0x3f,sizeof(miuse));
 8        dp[0]=miuse[0]=0;
 9        for(auto &p:tires)
10        {
11            ll x=p[0],y=p[1];
12            ll sum=0,cur=x;
13            for(int j=1;j<=numLaps;j++)
14            {
15                if(cur>(changeTime+x))break;
16                sum+=cur;
17                miuse[j]=min(miuse[j],sum);
18                cur*=y;
19            }
20        }
21      
22        for(int i=1;i<=numLaps;i++)
23        for(int j=0;j<i;j++)
24        dp[i]=min(dp[i],(dp[j]+miuse[i-j]+changeTime*(j==0?0:1)));
25        return dp[numLaps];
26     }
27 };

 

上一篇:leetcode : [62. 不同路径](https://leetcode-cn.com/problems/unique-paths/)


下一篇:LeetCode简单题之交替位二进制数