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 ...
随机推荐
- python 表达式
运算符 参考 https://www.runoob.com/python3/python3-basic-operators.html & https://www.runoob.com/pyth ...
- C# 数据类型(3)
动态类型 dynamic types 动态类型是后来引进的,他其实是一个static type,但是不像其他的静态类型,编译器不会检查你到底是啥类型(也不会检查你能不能去call某个'method') ...
- 2019牛客多校第九场B Quadratic equation(二次剩余定理)题解
题意: 传送门 已知\(0 <= x <= y < p, p = 1e9 + 7\)且有 \((x+y) = b\mod p\) \((x\times y)=c\mod p\) 求解 ...
- iPad Pro 涂鸦绘画实用技巧
iPad Pro 涂鸦绘画实用技巧 绘画,涂鸦,简笔画 pre-requirement iPad Pro Apple Pencil 实用技巧 zoom in, zoom out 应用矢量的特性,灵活缩 ...
- 2020 front-end interview
2020 front-end interview https://juejin.im/post/5e083e17f265da33997a4561 xgqfrms 2012-2020 www.cnblo ...
- CSS 实现文本的竖向排版
CSS 实现文本的竖向排版 demos .text{ word-wrap: break-word; width: 0px; } writing-mode .text{ writing-mode: ve ...
- Flutter: moor_flutter库,简化sqlite操作
入门 video moor_flutter 示例代码仓库 install dependencies: ... moor_flutter: dev_dependencies: ... moor_gene ...
- Masterboxan INC :个股出现疯涨,投资者需警惕股市泡沫
随着标普500指数自去年三月以来的暴涨,引发了很多亏损企业股价飙升,同时许多场外投资者盲目跟风,加剧了个股的疯涨.对于此现象,美国万事达资产管理有限公司不得不多次发文提醒投资者:个股出现疯涨,投资者需 ...
- 人物传记STEPHEN LITAN:去中心化存储是Web3.0生态重要组成
近期,NGK.IO的开发团队首席技术官STEPHEN LITAN分享了自己对去中心化储存的观点,以下为分享内容. 目前的存储方式主要是集中式存储,随着数据规模和复杂度的迅速增加,集中存储的数据对于系统 ...
- 【重榜?】.NET 6 Preview 1 开箱上手!带你尝试新版本更新!
目录 跨平台 UI 应用 Blazor 桌面应用 System.CommandLine 其它更新 ASP.NET Core 最近 .NET 6 Preview 1 发布了,.NET 统一是此版本的核心 ...