第十四届华中科技大学程序设计竞赛决赛同步赛beautifulland(代码片段)

tingtin tingtin     2022-12-20     163

关键词:

It’s universally acknowledged that there’re innumerable trees in the campus of HUST.
Now HUST got a big land whose capacity is C to plant trees. We have n trees which could be plant in it. Each of the trees makes HUST beautiful which determined by the value of the tree. Also each of the trees have an area cost, it means we need to cost ci area of land to plant.
We know the cost and the value of all the trees. Now HUSTers want to maximize the value of trees which are planted in the land. Can you help them?

输入描述:

There are multiple cases.
The first line is an integer T(T≤10), which is the number of test cases.
For each test case, the first line is two number n(1≤n≤100) and C(1≤C≤108), the number of seeds and the capacity of the land.
Then next n lines, each line contains two integer ci(1≤ci≤106) and vi(1≤vi≤100), the space cost and the value of the i-th tree.

输出描述:

For each case, output one integer which means the max value of the trees that can be plant in the land.
示例1

输入

复制
1
3 10
5 10
5 10
4 12

输出

复制
22



 1 #include <iostream>
 2 #include <cstring>
 3 #include <cstdio>
 4 #include <vector>
 5 #include <cmath>
 6 #include <algorithm>
 7 using namespace std;
 8 #define N  105
 9 #define mod 530600414
10 #define mem(a,b) memset(a,b,sizeof(a))
11 #define ll  long long 
12 #define inf 0x3f3f3f3f
13 int t,n,C;
14 int c[N],v[N];
15 int dp[10010];
16 int main()
17 
18     scanf("%d",&t);
19     while(t--)
20        scanf("%d%d",&n,&C);
21         mem(dp,inf);
22         dp[0]=0;
23         //dp[i] 要达到价值i,需要的最小空间。
24         for(int i=0;i<n;i++)  scanf("%d%d",&c[i],&v[i]);
25         for(int i=0;i<n;i++)
26         
27             for(int  j=10000;j-v[i]>=0;j--)
28                 dp[j]=min(dp[j],dp[j-v[i]]+c[i]);
29             
30             /*
31             for(int  j=0;j+v[i]<=10000;j++)
32                 dp[j+v[i]]=min(dp[j+v[i]],dp[j]+c[i]);
33                 1
34                 3 10
35                 5 10
36                 5 10
37                 4 12
38                 dp[24]=8,因此要逆序
39             
40             */
41         
42         for(int i=10000;i>=0;i--)
43             if(dp[i]<=C) 
44                 printf("%d
",i);
45                 break;
46             
47         
48     
49     return  0;
50 

 










长春理工大学第十四届程序设计竞赛(重现赛)m.orxzone

链接:https://ac.nowcoder.com/acm/contest/912/M题意:DaenerysStormborn,风暴中出生的丹尼莉丝,theUnburnt,烧不死的,QueenofMeereen,弥林女王,QueenoftheAndalsandtheRhoynarandtheFirstMen,安达尔人,罗伊那人,和先民的女王,LordoftheSevenKingdoms,七国之主 查看详情

长春理工大学第十四届程序设计竞赛(重现赛)h

H.ArithmeticSequence题目链接:https://ac.nowcoder.com/acm/contest/912/H题目数竞选手小r最喜欢做的题型是数列大题,并且每一道都能得到满分。你可能不相信,但其实他发现了一个结论:只要是数列,无论是给了通项还是给了递推式,无论... 查看详情

长春理工大学第十四届程序设计竞赛(重现赛)f(代码片段)

F.SuccessionediFixoracci题目链接:https://ac.nowcoder.com/acm/contest/912/F 题目:动态规划(Dynamicprogramming,简称dp)是一种通过把原问题分解为相对简单的子问题的方式求解复杂问题的方法。例如,假设小x一步能爬1层或2层台阶,求小x爬n... 查看详情

长春理工大学第十四届程序设计竞赛(重现赛)b(代码片段)

BBowlingGame题目链接:https://ac.nowcoder.com/acm/contest/912/B题目CUST的队员打完省赛后,小r带着大家去打保龄球。保龄球是一项难度非常高的游戏,然而这根本难不住校队成员,他们个个都很厉害(炸和)一发10个瓶都倒。尤其是小r,每次... 查看详情

浙江财经大学第十四届程序设计竞赛题解

 【题面pdf下载】链接:https://pan.baidu.com/s/1Eb16fHtNYMLrRk9QnXWa-g密码:dwn8【题目牛客网提交链接】【现场赛排名】链接:https://pan.baidu.com/s/1jfzH6-7BoPhEjnijGQK53w密码:y669 感谢各位大佬的参赛。 由于命题人水平不高,而且之前没... 查看详情

长春理工大学第十四届程序设计竞赛(重现赛)j.printout

链接:https://ac.nowcoder.com/acm/contest/912/J题意:小r为了打校赛,他打算去打字社打印一份包含世界上所有算法的模板。到了打字社,小r一看价格:总打印页数X0X0页以下(不含X0X0)x0x0元每页,X0∼X1X0∼X1页(不含X1X1)x1x1元每页,X1&si... 查看详情

第十四届华中科技大学程序设计竞赛--jvarioustree(代码片段)

链接:https://www.nowcoder.com/acm/contest/106/J来源:牛客网时间限制:C/C++1秒,其他语言2秒空间限制:C/C++32768K,其他语言65536K64bitIOFormat:%lld题目描述It’suniversallyacknowledgedthatthere’reinnumerabletreesinthecampusofH 查看详情

第十四届华中科技大学程序设计竞赛cprofessionalmanager并查集删除/虚点(代码片段)

题目描述It’suniversallyacknowledgedthatthere’reinnumerabletreesinthecampusofHUST.Thusaprofessionaltreemanagerisneeded.Yourtaskistowriteaprogramtohelpmanagethetrees.Initially,therearenforestsandforthei-thf 查看详情

第十四届全国大学生智能车竞赛竞赛技术报告下载链接

第十四届智能车竞赛技术报告下载链接 01下载报告  今天上午,看到有同学询问关于十四届智能车竞赛技术报告下载的询问。 实际上,之前第十四届的技术报告在百度上有, 只是没有能够提供下载链接。 由... 查看详情

第十四届华中科技大学程序设计竞赛jvarioustree数值型一维bfs/最小步数(代码片段)

链接:https://www.nowcoder.com/acm/contest/106/J来源:牛客网题目描述It’suniversallyacknowledgedthatthere’reinnumerabletreesinthecampusofHUST.AndtherearemanydifferenttypesoftreesinHUST,eachofwhichhasanumberrepresen 查看详情

第十四届华中科技大学程序设计竞赛kwalkingintheforest二分答案/最小化最大值(代码片段)

链接:https://www.nowcoder.com/acm/contest/106/K来源:牛客网题目描述It’suniversallyacknowledgedthatthere’reinnumerabletreesinthecampusofHUST.Nowyou'regoingtowalkthroughalargeforest.ThereisapathconsistingofNsto 查看详情

北京师范大学第十六届程序设计竞赛决赛-重现赛acfgi(代码片段)

A 塞特斯玛斯塔题目描述 quailty是一名狂热的ACM音游选手,沉迷各种音乐游戏,比如LunaticRave2,osu!之类的。今天,quailty玩的是国内游戏厂商雷亚(并不是赞助商)出品的一款音乐游戏Cytus。游戏中,玩家需要随着游戏界面... 查看详情

2021第四届浙江省大学生网络与信息安全竞赛技能赛决赛writeup,5题(代码片段)

文章目录1、Misc:asoul_lover2、Misc:site_log3、RE:最简单的逆向4、Web:远古特性5、Crypto:decode_and_decode1、Misc:asoul_lover题目表述:最近我旁边的灏妹天天上班第一句就是“Avaava”,还说要当安恒第一... 查看详情

2021第四届浙江省大学生网络与信息安全竞赛技能赛决赛writeup,5题(代码片段)

文章目录1、Misc:asoul_lover2、Misc:site_log3、RE:最简单的逆向4、Web:远古特性5、Crypto:decode_and_decode1、Misc:asoul_lover题目表述:最近我旁边的灏妹天天上班第一句就是“Avaava”,还说要当安恒第一... 查看详情

hdu6467简单数学题递推公式&&o优化乘法(广东工业大学第十四届程序设计竞赛)(代码片段)

...rce“字节跳动-文远知行杯”广东工业大学第十四届程序设计竞赛        解题思路: 但是这道题只推出递推 查看详情

第十七届智能汽车竞赛总决赛线上赛流程(代码片段)

...日程安排▲图1.1线上比赛日程安排二、竞赛规则  按照第十七届全国大学生智能车竞赛全国总决赛线上比赛规范中的条例执行(详细比赛规范见清华大学云盘:https://cloud.tsinghua.edu.cn/d/d5f8f9b7646c47b78dac/)。不接受与本比... 查看详情

第十四届浙江省赛

  题目真的是从易到难的顺序,而且跨度非常合理,只是看到榜单上后5题只有一支队做出来了一个,其他的没人做出来啊。。A-CookingCompetition水题。1#include<bits/stdc++.h>2usingnamespacestd;34intn,a;56intmain(){7//freopen("in","r",stdin);8in... 查看详情

第十六届全国大学生智能汽车竞赛总决赛ai视觉组线上赛细则(代码片段)

简介:本文对于参加2021年第十六届智能车竞赛全国总决赛线上比赛室内AI视觉组比赛细则。关键词:智能车竞赛,线上比赛,室内视觉AI一、比赛方式  由于AI视觉组的特殊识别任务,比如分赛区的竞赛中我... 查看详情