【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

开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的更多相关文章

  1. 【数位dp】【HDU 3555】【HDU 2089】数位DP入门题

    [HDU  3555]原题直通车: 代码: // 31MS 900K 909 B G++ #include<iostream> #include<cstdio> #includ ...

  2. 【HDU 5647】DZY Loves Connecting(树DP)

    pid=5647">[HDU 5647]DZY Loves Connecting(树DP) DZY Loves Connecting Time Limit: 4000/2000 MS ...

  3. -【线性基】【BZOJ 2460】【BZOJ 2115】【HDU 3949】

    [把三道我做过的线性基题目放在一起总结一下,代码都挺简单,主要就是贪心思想和异或的高斯消元] [然后把网上的讲解归纳一下] 1.线性基: 若干数的线性基是一组数a1,a2,a3...an,其中ax的最 ...

  4. 【HDU 2196】 Computer(树的直径)

    [HDU 2196] Computer(树的直径) 题链http://acm.hdu.edu.cn/showproblem.php?pid=2196 这题可以用树形DP解决,自然也可以用最直观的方法解 ...

  5. 【HDU 2196】 Computer (树形DP)

    [HDU 2196] Computer 题链http://acm.hdu.edu.cn/showproblem.php?pid=2196 刘汝佳<算法竞赛入门经典>P282页留下了这个问题 ...

  6. 【HDU 5145】 NPY and girls(组合+莫队)

    pid=5145">[HDU 5145] NPY and girls(组合+莫队) NPY and girls Time Limit: 8000/4000 MS (Java/Other ...

  7. 【hdu 1043】Eight

    [题目链接]:http://acm.hdu.edu.cn/showproblem.php?pid=1043 [题意] 会给你很多组数据; 让你输出这组数据到目标状态的具体步骤; [题解] 从12345 ...

  8. 【HDU 3068】 最长回文

    [题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=3068 [算法] Manacher算法求最长回文子串 [代码] #include<bits/s ...

  9. 【HDU 4699】 Editor

    [题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=4699 [算法] 维护两个栈,一个栈放光标之前的数,另外一个放光标之后的数 在维护栈的同时求最大前缀 ...

随机推荐

  1. Codeforces Round #256 (Div. 2) B

    B. Suffix Structures Bizon the Champion isn't just a bison. He also is a favorite of the "Bizon ...

  2. 【转】selenium自动化测试环境搭建

    转:http://blog.csdn.net/mao1059568684/article/details/17347853 第一步 安装JDK JDk1.7. 下载地址:http://www.orac ...

  3. Chrome改动浏览器User Agent

    对浏览器快捷方式右键->改动目标项为 C:\Users\LJ\AppData\Local\Google\Chrome\Application\chrome.exe --user-agent=&q ...

  4. Android多线程断点下载

    到华为后,信息管理特别严格,文件不能外发.所以好久都没写博客了,今天周日,老婆非要我学习.就闲来无事,写一篇博客,呵呵-- 前段时间,项目中提到了断点下载apk并静默安装的需求.本打算用应用市场成熟的 ...

  5. ios weak和strong的差别

    The difference is that an object will be deallocated as soon as there are no strong pointers to it. ...

  6. 读懂diff【转】

    本文转载自:http://www.ruanyifeng.com/blog/2012/08/how_to_read_diff.html 读懂diff   作者: 阮一峰 日期: 2012年8月29日 d ...

  7. Swift - 将字符串拆分成数组(把一个字符串分割成字符串数组)

    在Swift中,如果需要把一个字符串根据特定的分隔符拆分(split)成字符串数组,通常有如下两种方法: 1,使用componentsSeparatedByString()方法 1 2 3 4 5 l ...

  8. mysql5.7下面windows平台大小写敏感

    转自:https://blog.csdn.net/lrl219/article/details/52889582 根据网上的信息在my.ini下面的mysqld的配置下面添加lower_case_ta ...

  9. day63-webservice 04.JaxWsServerFactoryBean和SOAP1.2

    <wsdl:definitions xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:soap12="h ...

  10. 计算机网络自顶向下方法第2章-应用层(application-layer).2

    2.4 DNS:因特网的目录服务 2.4.1 DNS提供的服务 DNS的定义 实体层面看,DNS是一个由分层的DNS服务器实现的分布式数据库 协议层面看,DNS是一个使得主机能够查询分布式数据库的应用 ...