【hdu 6396】Swordsman
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
开k个优先队列。每个队列都满足从小到大那种。。
首先将所有的怪物加入到第一个队列中。
然后对于v[i]>=pq[i].top()的怪物,把这个怪物加入到i+1个队列。
然后每个队列都这么做。
直到不会有怪物从一个队列转移到另外一个队列为止。
当某个怪物在第k个队列中也满足转移之后。。那么这个怪物就是能被打败的了。。
每个队列就是一种检验吧。。。如果k个都能。。那就都满足了。。
【代码】
#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<int,int>,vector<pair<int,int> >,greater<pair<int,int> > >pq[6];
const int K = 5;
const int N = 1e5;
int n,k;
int v[K+5],a[N+5][K+5],b[N+5][K+5];
namespace IO {
const int MX = 4e7;
char buf[MX]; int c, sz;
void begin() {
c = 0;
sz = fread(buf, 1, MX, stdin);
}
inline bool read(int &t) {
while(c < sz && buf[c] != '-' && (buf[c] < '0' || buf[c] > '9')) c++;
if(c >= sz) return false;
bool flag = 0; if(buf[c] == '-') flag = 1, c++;
for(t = 0; c < sz && '0' <= buf[c] && buf[c] <= '9'; c++) t = t * 10 + buf[c] - '0';
if(flag) t = -t;
return true;
}
}
int main()
{
//freopen("D:\\rush.txt","r",stdin);
IO::begin();
int T;
IO::read(T);
while (T--){
for (int i = 1;i <= 5;i++) while (!pq[i].empty()) pq[i].pop();
IO::read(n);IO::read(k);
for (int i = 1;i <= k;i++)IO::read(v[i]);
for (int i = 1;i <= n;i++){
for (int j = 1;j <= k;j++) IO::read(a[i][j]);
for (int j = 1;j <= k;j++) IO::read(b[i][j]);
}
for (int i = 1;i <= n;i++) pq[1].push(make_pair(a[i][1],i));
bool ok = false;
int cnt = 0;
while (!ok){
ok = true;
for (int j = 1;j <= k;j++)
while (!pq[j].empty()){
int value = pq[j].top().first,id = pq[j].top().second;
if (v[j]<value) break;
if (j==k){
ok = false;
cnt++;
pq[j].pop();
for (int l = 1;l <= k;l++) v[l]+=b[id][l];
}else{
pq[j+1].push(make_pair(a[id][j+1],id));
pq[j].pop();
}
}
}
printf("%d\n",cnt);
for (int i = 1;i <= k;i++) {
printf("%d",v[i]);
if (i==k) puts("");else putchar(' ');
}
}
return 0;
}
【hdu 6396】Swordsman的更多相关文章
- 【数位dp】【HDU 3555】【HDU 2089】数位DP入门题
[HDU 3555]原题直通车: 代码: // 31MS 900K 909 B G++ #include<iostream> #include<cstdio> #includ ...
- 【HDU 5647】DZY Loves Connecting(树DP)
pid=5647">[HDU 5647]DZY Loves Connecting(树DP) DZY Loves Connecting Time Limit: 4000/2000 MS ...
- -【线性基】【BZOJ 2460】【BZOJ 2115】【HDU 3949】
[把三道我做过的线性基题目放在一起总结一下,代码都挺简单,主要就是贪心思想和异或的高斯消元] [然后把网上的讲解归纳一下] 1.线性基: 若干数的线性基是一组数a1,a2,a3...an,其中ax的最 ...
- 【HDU 2196】 Computer(树的直径)
[HDU 2196] Computer(树的直径) 题链http://acm.hdu.edu.cn/showproblem.php?pid=2196 这题可以用树形DP解决,自然也可以用最直观的方法解 ...
- 【HDU 2196】 Computer (树形DP)
[HDU 2196] Computer 题链http://acm.hdu.edu.cn/showproblem.php?pid=2196 刘汝佳<算法竞赛入门经典>P282页留下了这个问题 ...
- 【HDU 5145】 NPY and girls(组合+莫队)
pid=5145">[HDU 5145] NPY and girls(组合+莫队) NPY and girls Time Limit: 8000/4000 MS (Java/Other ...
- 【hdu 1043】Eight
[题目链接]:http://acm.hdu.edu.cn/showproblem.php?pid=1043 [题意] 会给你很多组数据; 让你输出这组数据到目标状态的具体步骤; [题解] 从12345 ...
- 【HDU 3068】 最长回文
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=3068 [算法] Manacher算法求最长回文子串 [代码] #include<bits/s ...
- 【HDU 4699】 Editor
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=4699 [算法] 维护两个栈,一个栈放光标之前的数,另外一个放光标之后的数 在维护栈的同时求最大前缀 ...
随机推荐
- h5-8 canvas
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- identity in sql server 批量插入history
https://stackoverflow.com/questions/1920558/what-is-the-difference-between-scope-identity-identity-i ...
- Adding a view
在添加View之前,之前的页面是下面这个样子,需要注意的是浏览器标题,以及浏览器的内容 https://docs.asp.net/en/latest/tutorials/first-mvc-app/a ...
- DDos攻击,使用深度学习中 栈式自编码的算法
转自:http://www.airghc.top/2016/11/10/Dection-DDos/ 最近研究了一篇论文,关于检测DDos攻击,使用了深度学习中 栈式自编码的算法,现在简要介绍一下内容论 ...
- [Database] 列出MSSQL所有数据库名、所有表名、所有字段名
1.获取所有数据库名 Select Name From Master..SysDatabases order By Name 2.获取所有表名 Select Name From SysObjects ...
- B - Letter(最小覆盖矩形)
Problem description A boy Bob likes to draw. Not long ago he bought a rectangular graph (checked) sh ...
- C - Pocket Book(set)
Problem description One day little Vasya found mom's pocket book. The book had n names of her friend ...
- c# 正则表达式regex心得
5.1. C#中的正则表达式的简介 C#中的Regex类处理正则表达式. 5.2. C#正则表达式的语法 5.3. C#中的正则表达式的特点 下面总结一些C#中的正则表达式相对于其他语言中的正则表达式 ...
- C# 添加应用程序包
项目中可能会遇到某些扩展方法不可以应用的情况,这时候需要在项目中引用程序包 步骤如下: 回车即可
- express jade ejs 为什么要用这些?
express是快速构建web应用的一个框架 线上文档 http://www.expressjs.com.cn/ 不用express行不行呢? 看了网上的回答:不用express直接搭,等你 ...