【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 [算法] 维护两个栈,一个栈放光标之前的数,另外一个放光标之后的数 在维护栈的同时求最大前缀 ...
随机推荐
- 一张游览PHP内核迷宫的藏宝图
PHP内核就像一个迷宫,假设没有一个纵览全局的图,仅仅是面对当中的一个点,就会像进了迷宫一样,走着走着就走到了死胡同.在这个迷宫里转悠了非常久之后,近期得到了一张PHP藏宝图.然后看着这张图去游览PH ...
- luogu2429 制杖题
题目大意 求不大于 m 的. 质因数集与给定有n个元素的质数集有交集的自然数之和. 数据范围 1 2 3 n*m<=10^7 4 5 n<=2,m<=10^9 6 7 n<=2 ...
- android 更新ui
https://www.cnblogs.com/rayray/p/3437048.html https://www.cnblogs.com/zhaoyanjun/p/5546683.html
- P1290sk抓螃蟹
背景 sk,zdq想在hzy生日之际送hzy几只螃蟹吃... 描述 现有n只螃蟹,每个在一个二维作标上,保证没有任何两个螃蟹重合.sk伸手抓螃蟹 了,他怕螃蟹的攻击,当他捉一只螃蟹时,其他螃蟹都朝这只 ...
- Gym-101915A Printing Books 模拟
题面 题意:给你N,X, X表示这本书从X开始编号,每个X是几位数,计数器就加几, 然后问你如果从X,开始编号,计数器为N的时候,翻了几页,不能刚好为N输出-1. (例如,5 99,答案为2,因为 ...
- IP与以太网的包收发操作
你好,这是<网络是怎样连接的>的第3篇读书笔记,第二章<用电信号传输TCP/IP>后半部分:IP与以太网的包收发操作. 先看下经典的TCP/IP四层模型: 通常,下层模块支撑上 ...
- 读入图片显示scipy.misc module has no attribute imread?
>>> import scipy >>> scipy.misc <module 'scipy.misc' from 'C:\Python27\lib\site ...
- 22.Generate Parentheses[M]括号生成
题目 Given n pairs of parentheses, write a function to generate all combinations of well-formed parent ...
- Python3没有dict.has_key方法
最近开始学习Python,安装上最新的Python3.3.3照书敲了一个小程序结果报错 'dict' object has no attribute 'has_key' 上网查也找不到解决办法,后来发 ...
- Solr.NET快速入门(五)【聚合统计,分组查询】
聚合统计 属性 说明 Min 最小值 Max 最大值 Sum 总和 Count 记录数,也就是多少行记录 Missing 结果集中,有多少条记录是空值 SumOfSquares 平方和(x1^2 + ...