当前位置:网站首页>[bjoi2019] platoon formation (Group backpack)
[bjoi2019] platoon formation (Group backpack)
2022-07-19 06:06:00 【lovesickman】
[BJOI2019] Row of opinion
Title Description
Small C Playing a game of arranging troops . There are... In the game n n n A castle , In each game, two players compete for these castles . Each player has m m m soldiers , You can go to the third party i i i The castle sent a i a_i ai Soldiers went to fight for the castle , So that the total number of soldiers does not exceed m m m.
If a player to the second i i i The number of soldiers sent by the castle Strictly More than twice the number of soldiers sent by the opponent , Then this player will occupy the castle , get i i i branch .
Now small C About to work with others s s s Two players fight in pairs , this s s s The plan of sending soldiers in the battle must be the same . Small C I learned about others through some ways s s s The strategy that a player will use , He wants to know what strategies he should use to maximize his total score .
Because the answer may not be unique , You just need to output small C The maximum total score .
Input format
The first line of input contains three positive integers s , n , m s,n,m s,n,m, Except for small C Number of players other than 、 Number of castles and soldiers per player .
Next s s s That's ok , Each row n n n Nonnegative integers , Represents a player's strategy , Among them the first i i i Number a i a_i ai Indicates that this player is going to the i i i The number of soldiers sent by the castle .
Output format
Output a non negative integer on a line , It means small C Maximum score obtained .
Examples #1
The sample input #1
1 3 10
2 2 6
Sample output #1
3
Examples #2
The sample input #2
2 3 10
2 2 6
0 0 0
Sample output #2
8
Tips
Examples 1 explain :
Small C The best strategy is to 1 1 1 Castle and 2 2 2 Each castle is dispatched 5 5 5 soldiers .
Data range :*
about 100 % 100\% 100% The data of :
1 ≤ s ≤ 100 1\le s \le 100 1≤s≤100
1 ≤ n ≤ 100 1\le n \le 100 1≤n≤100
1 ≤ m ≤ 20000 1\le m \le 20000 1≤m≤20000
For every player a i ≥ 0 a_i \ge 0 ai≥0, ∑ i = 1 n a i ≤ m \sum\limits_{i=1}^n a_i \le m i=1∑nai≤m
Learned some details of grouping backpacks .
For grouped knapsack boards .
First cycle the items , Volume , Finally, group decision .
for(int i=0;i<n;i++){
for(int j=m;j>=0;j--){
// Want to have j>=0
for(int k=0;k<s[i];k++){
//for(int k=s[i];k>=1;k--) It's fine too
if(j>=v[i][k]) f[j]=max(f[j],f[j-v[i][k]]+w[i][k]);
}
}
}
Empathy , castle , Volume , grouping ; At first, I was in the wrong order , It's always been wrong .
fo(j,1,n){
for(int k=m;k>=0;k--){
fo(i,1,s){
if(k-2*a[j][i]-1>=0)
f[k] = max(f[k],f[k-2*a[j][i]-1]+i*j);
}
}
}
int s,n,m;
int f[20010];// Just use m The maximum of
/* this s The plan of sending soldiers in the battle must be the same . */
void solve(){
cin>>s>>n>>m;
vector<vector<int>>a(n+1,vector<int>(s+1));
fo(i,1,s){
fo(j,1,n){
cin>>a[j][i];
}
}
fo(i,1,n){
sort(all(a[i]));
}
fo(j,1,n){
for(int k=m;k>=0;k--){
fo(i,1,s){
if(k-2*a[j][i]-1>=0)
f[k] = max(f[k],f[k-2*a[j][i]-1]+i*j);
}
}
}
// Wrong enumeration
// fo(j,1,n){
// fo(i,1,s){
// for(int k=m;k>=0;k--){
// if(k-2*a[j][i]-1>=0)
// f[k] = max(f[k],f[k-2*a[j][i]-1]+i*j);
// }
// }
// }
cout<<f[m]<<endl;
}
int main(){
solve();
return 0;
}
There is also a problem that may make the snake superfluous : The total number of soldiers does not exceed m , So the state definition is no more than , It cannot be exactly equal to .
边栏推荐
- Wireless charging chip IC
- 4-20ma转4-20ma 0-5v转0-5v 模拟信号隔离变送器
- ES聚合分析报错:“reason“ : “Text fields are not optimised for operations
- Introduction to goroutine, a high concurrency feature of golang
- [detailed tutorial installation] [configuration] auxiliary plug-ins about eslint in vscode
- Complete scheme diagram of lth7 five pin chip fs4054 charging circuit principle
- RestAPI实现聚合(黑马教程)
- Hra2460d-2w high voltage power supply high voltage module - high voltage - high precision hra2460d-2w
- Fs68001 wireless charging SOC chip has simple periphery and schematic diagram of 5W wireless charging scheme
- 解决Cannot read properties of null (reading ‘pickAlgorithm‘)
猜你喜欢
Material and application circuit diagram of 0-10V, 4-20mA current voltage to PWM isolation converter
go语言介绍及应用场景分析
升高压模块隔离模块HRA2460D-2W
Introduction to Darwin streaming server
软考初、中、高级考试全体验
配置VsCode中‘log’快捷键去掉console.log(‘‘);中的分号;
[详细教程安装][配置] VsCode中关于Eslint的辅助插件
Complete scheme diagram of lth7 five pin chip fs4054 charging circuit principle
DSL实现自动补全查询
【力扣】另一棵树的子树
随机推荐
Qtss callback routine
Vscode instant English translation plug-in [translation (English Chinese Dictionary)]
Acwing第57场周赛(AK)
压力应变桥信号处理光电隔离放大器
Go language introduction and application scenario analysis
【力扣】二叉树的最大深度
Darwin reflex summary
4-20mA to 0-5khz, 5V pulse converter
模拟信号深入讨论4-20mA电流信号的传输距离
2022/07/14 学习笔记 (day07)数组
[transfer] Darwin streaming server core code analysis
2022/07/12 学习笔记 (day05)JS内置函数
[simple and fast] after startup, the desktop is normal, and the taskbar below is unresponsive / the mouse keeps turning
Wireless charging chip IC
[antdv: Each record in table should have a unique `key` prop,or set `rowKey` to an unique.....
配置VsCode中‘log’快捷键去掉console.log(‘‘);中的分号;
最长括号匹配 (线性DP)
[USACO06DEC]The Fewest Coins G(混合背包)
谷歌浏览器不能手动修改cookies,cookie报红标红
vscode one dark和c扩展变量颜色冲突 设置settings.json如下即可