当前位置:网站首页>Contest3145 - the 37th game of 2021 freshman individual training match_ A: Prizes
Contest3145 - the 37th game of 2021 freshman individual training match_ A: Prizes
2022-07-06 15:10:00 【This question AC sleep again】
//
problem A: Prize
The time limit : 1.000 Sec Memory limit : 128 MB
Title Description
Na Zha, the Third Prince of King li of tota , High skill , He wants to catch up with the Olympic Games , Open a mind Olympic Games , The prize of the winner is refined “ helium -3” Crystal structure ;
This substance is abundant on the moon There is , It is colorless 、 Tasteless helium isotopes , It plays an important role in nuclear fusion research .
helium -3 Or a kind of Absolutely clean energy , Because it doesn't have the nature of releasing itself , Therefore, no radioactive waste will be produced . But if from The crystal will be transported back to earth on the moon ? Na Zha said : Use my belly pocket !
Of course, his belly pocket is vulnerable to solar wind and other factors Influence , The carrying capacity cannot exceed k(1<=k<=100000), Beyond that , The belly pocket won't fly ;
This k value Na Zha will tell you , It will also tell you the weight of each crystal . Your task is to make this belly bag transport more crystals at a time .
Input
There are two lines The first line has two positive integers n and k, Separated by a space . Express n Crystal , The maximum carrying capacity of the belly pocket is k. The second line has n No more than one. 10000 The positive integer , respectively n Weight of crystals , Use a space between numbers Grid separation .
Output
There is only one line , This line has only one positive integer , It means that nazha's belly pocket can be transported back at one time The maximum crystal weight of .
The sample input Copy
5 15
2 4 4 8 10
Sample output Copy
14
Tips
[ Data restrictions ]
40% The data of : 1<=n<=20
100% The data of : 1<=n<=100//
// dp
#include<bits/stdc++.h>
using namespace std;
const int MAXN=1e5+6;
int a[111],dp[111][MAXN];
int main()
{
int n,k,i,j;
while( ~scanf("%d%d",&n,&k) )
{
memset( a,0,sizeof( a ) );
memset( dp,0,sizeof( dp ) );
for( i=1;i<=n;i++ ) scanf("%d",&a[i]);
for( i=1;i<=n;i++ )
{
for( j=1;j<=k;j++ )
{
if( j<a[i] ) dp[i][j]=dp[i-1][j];
else dp[i][j]=max( dp[i-1][j],dp[i-1][j-a[i]]+a[i] );
}
}
printf("%d\n",dp[n][k]);
}
return 0;
}//
find:
01 How to solve it with one-dimensional array 边栏推荐
- Statistics 8th Edition Jia Junping Chapter 4 Summary and after class exercise answers
- Sorting odd and even subscripts respectively for leetcode simple problem
- Face and eye recognition based on OpenCV's own model
- Thinking about three cups of tea
- Build your own application based on Google's open source tensorflow object detection API video object recognition system (I)
- CSAPP Shell Lab 实验报告
- Fundamentals of digital circuits (II) logic algebra
- Servlet
- 自动化测试你必须要弄懂的问题,精品总结
- How to solve the poor sound quality of Vos?
猜你喜欢

Login the system in the background, connect the database with JDBC, and do small case exercises
软件测试工作太忙没时间学习怎么办?

UCORE lab2 physical memory management experiment report

Build your own application based on Google's open source tensorflow object detection API video object recognition system (I)

Opencv recognition of face in image

DVWA exercise 05 file upload file upload

The number of reversing twice in leetcode simple question

CSAPP家庭作業答案7 8 9章
![Cadence physical library lef file syntax learning [continuous update]](/img/0b/75a4ac2649508857468d9b37703a27.jpg)
Cadence physical library lef file syntax learning [continuous update]
软件测试行业的未来趋势及规划
随机推荐
Login the system in the background, connect the database with JDBC, and do small case exercises
全网最详细的postman接口测试教程,一篇文章满足你
Keil5 MDK's formatting code tool and adding shortcuts
Investment should be calm
The minimum number of operations to convert strings in leetcode simple problem
Global and Chinese market of barrier thin film flexible electronics 2022-2028: Research Report on technology, participants, trends, market size and share
Report on the double computer experiment of scoring system based on 485 bus
Sorting odd and even subscripts respectively for leetcode simple problem
Daily code 300 lines learning notes day 9
Thinking about three cups of tea
自动化测试你必须要弄懂的问题,精品总结
"If life is just like the first sight" -- risc-v
CSAPP Shell Lab 实验报告
In Oracle, start with connect by prior recursive query is used to query multi-level subordinate employees.
MySQL数据库(五)视 图 、 存 储 过 程 和 触 发 器
Logstack introduction and deployment -- elasticstack (elk) work notes 019
ucore lab7 同步互斥 实验报告
Stc-b learning board buzzer plays music 2.0
Rearrange spaces between words in leetcode simple questions
Pedestrian re identification (Reid) - Overview