2019 GDUT Rating Contest II : Problem G. Snow Boots
题面:
G. Snow Boots
题目描述:
题目分析:
1 #include <cstdio> 2 #include <cstring> 3 #include <iostream> 4 #include <cmath> 5 #include <set> 6 #include <algorithm> 7 using namespace std; 8 const int inf = 0x3f3f3f3f; 9 int n, b; 10 int f[255], s[255], d[255]; 11 int dp[555]; 12 13 void test(){ 14 cout <<endl; 15 for(int i = 1 ; i <= n ; i++){ 16 printf("dp[%d] : %d\n", i, dp[i]); 17 } 18 } 19 20 int main(){ 21 cin >> n >> b; 22 for(int i = 1; i <= n; i++){ 23 cin >> f[i]; 24 } 25 for(int i = 1; i <= b; i++){ 26 cin >> s[i] >> d[i]; 27 } 28 29 memset(dp, inf, sizeof(dp)); 30 dp[1] = 0; //第1个瓷砖丢弃0双鞋子,可以表示当前正在穿第1双鞋子 31 32 33 for(int i = 1; i <= n; i++){ 34 int u = dp[i]+1; //第i个瓷砖丢器正在穿第u双鞋子 35 for(int j = u; j <= b; j++){ //穿第j双鞋子到下一个瓷砖 36 for(int k = 1; k <= d[j]; k++){ //到第i+k个瓷砖 37 if(f[i+k] <= s[j] && f[i] <= s[j]){ //穿的鞋子高于等于当前瓷砖和下一个瓷砖 38 dp[i+k] = min(dp[i+k], j-1); //穿第j双鞋子到第i+k个瓷砖,丢弃了j-1双鞋子 39 //min()是更新操作,也就是如果其他瓷砖到达第i+k个瓷砖有更小的丢弃数量就更新为更小的 40 } 41 } 42 } 43 } 44 45 //test(); 46 47 cout << dp[n] << endl; 48 49 return 0; 50 }
转载于:https://www.cnblogs.com/happy-MEdge/p/10405028.html
2019 GDUT Rating Contest II : Problem G. Snow Boots相关推荐
- 2019 GDUT Rating Contest I : Problem H. Mixing Milk
题面: H. Mixing Milk Input file: standard input Output file: standard output Time limit: 1 second Memory ...
- 2019 GDUT Rating Contest II : A. Taming the Herd
题面: A. Taming the Herd Input file: standard input Output file: standard output Time limit: 1 second Me ...
- 2021 ICPC Asia Regionals Online Contest (II) Problem G. Limit
The 2021 ICPC Asia Regionals Online Contest (II) Problem G. Limit 在欧教的指导下,复习了下高数知识,写下了这题的题解- 做这道题之前, ...
- 2020 GDUT Rating Contest II (Div. 2) A. Fence Planning
来源 codeforces 2020 GDUT Rating Contest II (Div. 2) CF链接 题目: Farmer John's N cows, conveniently numbe ...
- 2020 GDUT Rating Contest III (Div2)
2020 GDUT Rating Contest III (Div2) A Wormhole Sort 题意: 给出N个打乱顺序的数,和M条边(a,b,c)表示在a位置的数可以和在b位置的数交换,这条 ...
- 2020 GDUT Rating Contest I (Div. 2) A.Cow Gymnastics
来源 codeforces 2020 GDUT Rating Contest I (Div. 2) 题目: A. Cow Gymnastics In order to improve their ph ...
- 2020 GDUT Rating Contest III (Div. 2) B - Loan Repayment 题解
原题 题目大意 给出NNN,KKK,MMM,假定已经给了GGG加仑奶,定义N−GX\frac{N-G}{X}XN−G为YYY,YYY最小为MMM,在KKK天后至少给NNN加仑奶,求最大的XXX. 题 ...
- 2020 GDUT Rating Contest I A. Cow Gymnastics
A. Cow Gymnastics 链接 题目描述 有n头牛一起参加了k次比赛,给出k次比赛的排名,问共有几组牛满足 其中一头牛每次比赛都比另一头厉害. 题目分析 由于数据量比较小(1<=k&l ...
- 2020 GDUT Rating Contest I (Div. 2) A - Cow Gymnastics 题解
好吧--是时候补一下题解了 原题 题目大意 给出n只牛,k次排序,如果有一只牛一直比另外一只牛更前算作一对,输出一共有多少对. 题目分析 水题(数据规模小),一开始初始化全部都可以,然后一个个删去就行 ...
最新文章
- Pytorch中的数据加载
- ubuntu mysql 中午_Ubuntu更改MySQL字符集UTF-8,正确显示中文
- BootStrap中Affix控件的使用方法及如何保持布局的美观
- HDU1010【走迷宫】Tempter of the Bone-------2015年1月26日
- 龙芯mips64 Javajdk下载
- css只设置背景图片半透明,css 设置背景色或图片半透明的方法(图文)
- Vue项目 设置实时时间(年月日 时分秒)两种方法
- 用postman GET调试阿里云银行卡二、三、四要素实名认证
- VirtualBox 安装增强功能错误
- 云服务器win10系统初始密码,win10进入安全模式需要密码初始密码是什么
- ERROR StatusLogger No log4j2 configuration file found. Using default configuration解决方式
- 【编程题】【Scratch一级】2019.12 飞向太空
- SKYLAKE平台安装win7步骤(U盘)
- 【营销获客三】信贷细分客群研究——小微企业主
- 谈谈阿里云弹性公网IP
- 面对逆境:你是胡萝卜、鸡蛋还是咖啡豆
- 来一份Android动画全家桶(下篇)
- Niagara物联网框架机制二(笔记)
- 基于微信小程序的科普之家小程序-计算机毕业设计
- java interface 理解