当前位置:网站首页>P1926 little bookboy - question brushing Army (DP backpack (01 backpack) state transition equation)
P1926 little bookboy - question brushing Army (DP backpack (01 backpack) state transition equation)
2022-07-21 03:18:00 【Leng Chi】
Background
Mathematics is fire , Light up the physical light ; Physics is light , Illuminate the way of Chemistry ; Chemistry is the way , The pit leading to creatures ; Creatures are pits , Bury rational people . Classical Chinese is fire , Light up the palace lamp of history ; History is a lamp , Illuminate the road of society ; Society is the way , To the pit of philosophy ; Philosophy is a pit , Bury liberal arts students .—— Small A
Title Description
Small A“ Brush problem ” Very rampant , Blatantly “ Brush problem ”. He found it in the little book boy now n Like what he likes “ subject ”, Every time “ topic ” All of them need time , And the teacher assigned m Item job , Each assignment has its required time and score , Teacher regulation k A score above is considered a pass . Small A only r Unit time , He wants to pass more “ Brush problem ”.
Input format
first line :n m k r. The second line :n Number , For each “ topic ” His needs time . The third line :m Number . Indicates the time required for each assignment . In the fourth row :m Number . Represents the score of each assignment .
Output format
a number , For little A Can brush several questions
I/o sample
Input #1
3 4 20 100 15 20 50 10 15 40 40 5 5 10 15
Output #1
2
explain / Tips
There is no failure
about 100% The data of ,n≤10,m≤10,k≤50,r≤150
dp The method is the maximum value that can be obtained in this state .
( as for dp I'll try to get it out as soon as possible , Let novices understand dp Method )
First use dp Find the specified time , Score you can get , Then find the first time that is just greater than or equal to the passing score , Subtract the specified time , You will get enough time to brush your own topics .
#include <iostream>
#include <algorithm>
using namespace std;
int n,m,k,r;
int time1[1000];
int time2[1000];
int score[1000];
int dp[1000];
int lt=0;
int max1=0;
int main()
{
cin>>n>>m>>k>>r;
for(int i=1;i<=n;i++)
{
cin>>time1[i];
}
for(int i=1;i<=m;i++)
{
cin>>time2[i];
}
for(int i=1;i<=m;i++)
{
cin>>score[i];
}
for(int i=1;i<=m;i++)
{
for(int t=r;t>=time2[i];t--)
{
dp[t]=max(dp[t],dp[t-time2[i]]+score[i]);
}
}
for(int i=1;i<=r;i++)
{
if(dp[i]>=k)
{
lt=r-i;
break;
}
}
sort(time1,time1+n);
for(int i=1;i<=n;i++)
{
lt=lt-time1[i];
if(lt<0)
{
break;
}
max1++;
}
cout<<max1<<endl;
return 0;
}
边栏推荐
猜你喜欢
用户登录Demo
冒泡排序/堆排序
[dish of learning notes, dog learning C] get familiar with common keywords, define constants and macros
Apache Doris connects to SQL server through ODBC
How to realize file sharing access on computer in win10
Niuke bm6 judges whether there is a ring in the linked list
win10如何实现电脑上文件共享访问
阿里矢量图库 当前页全选
统一返回数据格式
Apache Doris uses the Prometheus alertmanager module to send exception information to the nail alarm group
随机推荐
文件编辑器vim的使用和介绍
DOM -- event syntax
A. Subtle Substring Subtraction
[note] logstash environment setup and installation configuration
DOM -- operation document tree and its cases
[dish of learning notes dog learning C] chain access, function declaration and definition, goto statement
Apache Doris ODBC appearance PostgreSQL User Guide
【学习笔记之菜Dog学C】初识操作符和原码、反码、补码
(洛谷)P1605迷宫(一入深搜苦如海,从此时间是大die)
Towards Representation Alignment and Uniformity in Collaborative Filtering
【学习笔记之菜Dog学C】函数递归
Rpc:thrift framework
【学习笔记之菜Dog学C】链式访问、函数的声明和定义、goto语句
记一次笔记:Oracle条件语句
ECMAScript新特性
OpenLayers 画圆画椭圆
Apache Doris rapid deployment operation and maintenance guide based on ansible
C语言写一个环形广告跑马灯或改为表白系统
使用 poi 导入导出
2022-07-19-use shell to activate CONDA environment