当前位置:网站首页>[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 .
边栏推荐
- 【力扣】相同的树
- FS68001无线充SOC芯片外围简单,5W无线充方案原理图
- Qtss callback routine
- Digital signal isolation module adum1401arwz yadeno in stock
- Introduction to goroutine, a high concurrency feature of golang
- 2021-09-15
- 升高压模块隔离模块HRA2460D-2W
- [详细教程安装][配置] VsCode中关于Eslint的辅助插件
- MySQL Workbench基本使用 【创建一个数据表】
- 简单Chrome脚本 自动跳过b站视频播放结束后的的充电鸣谢页面
猜你喜欢

2022/07/14 学习笔记 (day07)数组

【力扣】另一棵树的子树

VSCode 即时英文翻译插件 【翻译(英汉词典)】

ES聚合分析报错:“reason“ : “Text fields are not optimised for operations

Tips for using tp4054 charging IC -- used in conjunction with Zhongke Lanxun ab5365b

數學基礎課2_歐拉函數,線性篩,擴歐

4路编码器脉冲计数器,8路DO,Modbus TCP模块

5-17陕西科技大学的隐藏学生服务

DSL实现自动补全查询

2021-11-17 esp32 pin reference
随机推荐
MEX and Increments
2021-09-15
【力扣】另一棵树的子树
5V boost charging 8.4v chip
4路编码器脉冲计数器,转速测量,8路DO,Modbus TCP数据采集模块
嵌入式C语言volatile作用
4-20mA to 0-5khz, 5V pulse converter
minio安装部署及简单使用
设置索引库结构,给用户添加可自动补全的suggestion,并将一些字段变成集合放到suggestion里面去
golang高并发特性goroutine介绍
【力扣】翻转二叉树
Hm8203 linear two string charging management controller IC
Acwing第58场周赛(AK)
Acwing第 59 场周赛(AK)
【力扣】单值二叉树
配置VsCode中‘log’快捷键去掉console.log(‘‘);中的分号;
High voltage module isolation module hra2460d-2w
【转】Darwin Streaming Server 核心代码分析
【简单快速】启动后桌面正常下方任务栏无反应/鼠标一直转圈
Conversion, isolation and transmission of international standard signals 0-5v/0-10v/1-5v, 0-10ma/0-20ma/4-20ma, etc