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 ...
随机推荐
- leetcode 36 有效的数独 哈希表 unordered_set unordersd_map 保存状态 leetcode 37 解数独
leetcode 36 感觉就是遍历. 保存好状态,就是各行各列还有各分区divide的情况 用数组做. 空间小时间大 class Solution { public: bool isValidSud ...
- BZOJ1001 狼抓兔子(网络流转最短路:对偶图)
题意: 给一个如图形式的\(n*m\)的方格,从左上走到右下,给出边权,问分成两块所需的最小代价.\(n,m\leq1000\). 思路: 显然是个最小割,但是\(O(n^2m)\)的复杂度很高,虽然 ...
- linux通识
linux是服务器应用领域的开源且免费的多用户多任务操作系统的内核. 以下是对上述论断的解释: 操作系统 简言之,操作系统乃是所有计算设备的大管家,小到智能手表,大到航天航空设备,所有需要操控硬件的地 ...
- u-boot 移植 --->2、在u-boot新增SOC和板子
本次主要是要新增一个samsung的芯片到u-boot中,网上查阅资料发现s5pc1xx是与手上的S5PV210的友善的Tiny版子寄存器兼容的比较多,所以就准备以他为基础增加一个我的板子的支持到u- ...
- Set DSL in Ubuntu 18.04
Reference Solutions: Ctrl+Atl+t Type nmcli con edit type pppoe con-name ANY_NAME_OF_DSL_YOU_LIKE, wh ...
- TypeScript Developer Roadmap
TypeScript Developer Roadmap https://github.com/xgqfrms/TypeScript-Developer-Roadmap https://typescr ...
- Linux kill All In One
Linux kill All In One kill -9 kill $ kill <PID> $ ps -ef | grep node $ sudo kill -9 <PID> ...
- ADN vs CDN All In One
ADN vs CDN All In One Netlify & JAMstack https://app.netlify.com/teams/xgqfrms/sites ADN Applica ...
- React & Strict Mode
React & Strict Mode https://reactjs.org/docs/strict-mode.html#detecting-unexpected-side-effects ...
- React-Native Tutorials
React-Native Tutorials https://egghead.io/courses/react-native-fundamentals part free https://egghea ...