Codeforces Beta Round #37 B. Computer Game 暴力 贪心
来源:互联网 发布:node express 中间件 编辑:程序博客网 时间:2024/06/07 01:31
题目链接:这里
题意:有一个boss有hp点血,然后每秒钟回复reg。现在你有n个魔法,每个魔法只能在BOSS的血量大于p[i]%的时候使用,会给boss挂上一个每秒钟掉d[i]的buff。现在问你你怎么使用这个魔法,才能让boss死的最快。
解法:贪心,每一秒钟使用最厉害的技能就好了…… 然后直接暴力莽一波
//CF 37B#include <bits/stdc++.h>using namespace std;const int maxn = 1005;vector <pair<int, int> > ans;int b[maxn], c[maxn], vis[maxn];int main(){ int n, hp, reg; scanf("%d%d%d", &n, &hp, ®); for(int i = 0; i < n; i++) scanf("%d%d", &b[i], &c[i]); int cur = hp, dmg = 0, t = 0, flag = 0; while(cur > 0){ cur -= dmg; cur += reg; cur = min(cur, hp); if(cur <= 0) break; int pos = -1; for(int i = 0; i < n; i++){ if(!vis[i] && b[i]*hp >= 100*cur){ if(pos == -1 || c[i] > c[pos]){ pos = i; } } } if(pos != -1){ vis[pos] = 1; dmg += c[pos]; ans.push_back(make_pair(t, pos+1)); } else{ if(cur == hp){ flag = 1; break; } } ++t; } if(flag) return puts("NO"), 0; else{ puts("YES"); printf("%d %d\n", t, ans.size()); for(int i = 0; i < ans.size(); i++){ cout << ans[i].first << " " << ans[i].second << endl; } } return 0;}
0 0
- Codeforces Beta Round #37 B. Computer Game 暴力 贪心
- Codeforces Problem 37B - Computer Game
- Codeforces Round #357 (Div. 2) B. Economy Game (暴力)
- Codeforces Round #307 (Div. 2) B. ZgukistringZ (贪心 + 暴力)
- Codeforces Beta Round #60-B
- Codeforces Beta Round #2 B
- Codeforces Beta Round #3 B
- Codeforces Beta Round #46 (Div. 2), problem: (D) Game 贪心YY
- 【位运算+暴力】Codeforces Beta Round #86 (Div. 2 Only) B
- Educational Codeforces Round 27 A B 暴力+贪心 C 贪心+排序
- Codeforces Beta Round #77 (Div. 1 Only), problem: (B) Lucky Numbers 数位DP+剪枝DFS+贪心
- Codeforces Beta Round #75 (Div. 2) / 92B Binary Number(贪心)
- CodeForces387B B - George and Round 贪心+暴力
- Codeforces Round #398 (Div. 2) -- B. The Queue (贪心+暴力)
- Codeforces Beta Round #28 B题
- 【dp】Codeforces Beta Round #2 B
- Codeforces Beta Round #1(A,B)
- Codeforces Beta Round #1 A B C
- SSH(struts+spring+hibernate)框架搭建流程
- Centos7安装并配置mysql5.6
- VS2010中创建C#的位图(BitMap)的方法与步骤
- Mac Virtualbox Centos Httpd部署安装
- Convert Sorted Array to Binary Search Tree问题及解法
- Codeforces Beta Round #37 B. Computer Game 暴力 贪心
- Android 屏幕密度等级
- 什么是协作?什么是用例实现?
- 【SinGuLaRiTy-1009】 模板-读入优化 & 输出优化
- 异常------》hibernate异常---》Duplicate collection role mapping(重复映射)
- 男人皮肤黑是咋回事
- 隐藏的Fragment优越性 可生存性
- 关于IOS一些有的没的 – IOS多线程
- 正则表达式3分钟看完入门代码及含义