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 }
2019 GDUT Rating Contest II : Problem G. Snow Boots的更多相关文章
- 2019 GDUT Rating Contest II : Problem F. Teleportation
题面: Problem F. Teleportation Input file: standard input Output file: standard output Time limit: 15 se ...
- 2019 GDUT Rating Contest I : Problem G. Back and Forth
题面: G. Back and Forth Input file: standard input Output file: standard output Time limit: 1 second Mem ...
- 2019 GDUT Rating Contest II : Problem C. Rest Stops
题面: C. Rest Stops Input file: standard input Output file: standard output Time limit: 1 second Memory ...
- 2019 GDUT Rating Contest II : Problem B. Hoofball
题面: 传送门 B. Hoofball Input file: standard input Output file: standard output Time limit: 5 second Memor ...
- 2019 GDUT Rating Contest III : Problem E. Family Tree
题面: E. Family Tree Input file: standard input Output file: standard output Time limit: 1 second Memory ...
- 2019 GDUT Rating Contest III : Problem C. Team Tic Tac Toe
题面: C. Team Tic Tac Toe Input file: standard input Output file: standard output Time limit: 1 second M ...
- 2019 GDUT Rating Contest III : Problem D. Lemonade Line
题面: D. Lemonade Line Input file: standard input Output file: standard output Time limit: 1 second Memo ...
- 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 ...
- 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 ...
随机推荐
- Watch the Wifi: Visually Stunning Look at the Digital World Invading Cities (video)
http://singularityhub.com/2011/04/01/watch-the-wifi-visually-stunning-look-at-the-digital-world-inva ...
- TypeScript TSConfig All In One
TypeScript TSConfig All In One tsconfig.json https://www.typescriptlang.org/tsconfig https://www.typ ...
- set CSS style in js solutions All In One
set CSS style in js solutions All In One css in js set each style property separately See the Pen se ...
- Iterators & Generators in depth
Iterators & Generators in depth https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/It ...
- MDN 文档高级操作进阶教程
MDN 文档高级操作进阶教程 MDN 文档, 如何优雅的使用 MDN 文档上的富文本编辑器 pre & 语法高亮器 code & note box source code 上传附件 i ...
- PHP & LAMP & WAMP
PHP & LAMP & WAMP https://github.com/xgqfrms/DataStructure/issues/7#issuecomment-430538438 h ...
- D language
D language https://en.wikipedia.org/wiki/D_(programming_language) Dart https://dlang.org/ flutter fr ...
- 比特币市场活跃,VAST发行在即!
截至1月25日13:30,BTC合约多空持仓人数比为1.44,市场做多人数占据优势:季度合约基差保持在1255美元上方,永续合约资金费率为正,交割及永续合约持仓总量为19.5亿美元,总体上多军占优:B ...
- Nice!JavaScript基础语法知识都在这儿了
好好学习,天天向上 本文已收录至我的Github仓库DayDayUP:github.com/RobodLee/DayDayUP,欢迎Star 转载请注明出处! 链接:https://blog.csdn ...
- 【Notes_3】现代图形学入门——基础变换、MVP变换模型
基础变换(二维) 三维变化与二维变换矩阵类似 齐次坐标下的基础变换 Scale: \[S(s_x,s_y) =\begin{pmatrix} s_x &0 &0\\ 0 & s ...