当前位置:网站首页>1255. Dynamic programming for state compression of the word set with the highest score
1255. Dynamic programming for state compression of the word set with the highest score
2022-07-19 03:51:00 【Empress Yu】
Method : Dynamic programming
- Count , Mapping to 26 Letters
- Fill in the score of a single word , By the way, verify whether you can use existing characters to form words
- Try to continue filling ,dp front 26 Represents the number of occupied letters , The first 27 Delegate scores
class Solution {
public long sellingWood(int m, int n, int[][] prices) {
long[][] dp = new long[m+1][n+1];
for(int [] price:prices){
dp[price[0]][price[1]]=price[2];
}
for(int i = 1; i <= m; i++){
for(int j = 1; j <= n; j++){
for(int t = 0 ; t<=j;t++) dp[i][j]=Math.max(dp[i][j],dp[i][t]+dp[i][j-t]);
for(int t = 0 ; t<=i;t++) dp[i][j]=Math.max(dp[i][j],dp[t][j]+dp[i-t][j]);
}
}
return dp[m][n];
}
} Time complexity :O(n*2^n)
Spatial complexity :O(2^n)
边栏推荐
- Work fishing clock simulator wechat applet source code
- AcWing:第60场周赛
- 初识ESP8266(二)————搭建网络服务器实现远程控制
- QT OpenGL moves 3D objects with mouse and keyboard (set camera)
- Explanation of Hoff transformation
- Private storage space of threads
- 为什么越来越多人开始选择过“低配生活”?
- Understanding of random forest
- HCIP实验5
- laradock重启mysql 找来的
猜你喜欢

ulsm配置案例

MySQL addition, deletion, query and modification (basic)

Work fishing clock simulator wechat applet source code

清晰扫描件怎么弄:试试扫描裁缝ScanTailor Advanced吧 | 含scantailor使用方法

电脑绘画软件哪个好用:试试Artweaver Plus吧,媲美sai绘画软件 | 最新版本的artweaver下载

基于Pandoc与VSCode的 LaTeX环境配置

波士顿房价分析作业总结

Hcip Experiment 5

渗透测试-01信息收集

Group convolution
随机推荐
L1, L2 norm
[nodejs] npm/nrm cannot load the file because the script solution is prohibited in this system
电脑端实现微信双开(登录两个微信)
Paper template format of mathematical modeling competition
Qt OpenGL 通过鼠标和键盘移动三维物体(设置相机)
Chapter II linear table
LeetCode 931:下降路径最小和
automake中文手册_incomplete
Chapter II: news topic classification tasks
TS的使用案例——贪吃蛇
2.9.2 digital type processing and convenient methods of ext JS
central limit theorem
ResNet
(21)Blender源码分析之鼠标按下消息添加到队列的过程
Matlab在线性代数中的应用
[C语言勘误]数组长度的函数内获取方式错误
【LeetCode】735. 行星碰撞
劍指 Offer 59 - II. 隊列的最大值
【论文摘要】记录一些感兴趣的摘要和特别领域论文的方法截图。
HCIP第八天笔记