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

【题意】

在这里输入题意

【题解】

开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. Oracle GoldenGate 支持 从SAP HANA database抽取或者复制数据到SAP HANA database 吗?

    Oracle GoldenGate 支持 从SAP  HANA database抽取或者复制数据到SAP HANA database 吗? 来源于: Does Oracle GoldenGate Su ...

  2. linux中O(1)调度算法与全然公平(CFS)调度算法

    一.O(1)调度算法 1.1:优先级数组 O(1)算法的:一个核心数据结构即为prio_array结构体. 该结构体中有一个用来表示进程动态优先级的数组queue,它包括了每一种优先级进程所形成的链表 ...

  3. 读取url中某个值

    url="http://test.plus.1course.cn/Task/Display?id=25942" print(url) result=url.split('/')[- ...

  4. POJ 1442 Black Box(优先队列)

    题目地址:POJ 1442 这题是用了两个优先队列,当中一个是较大优先.还有一个是较小优先. 让较大优先的队列保持k个.每次输出较大优先队列的队头. 每次取出一个数之后,都要先进行推断,假设这个数比較 ...

  5. gephi——怎样上传节点表格而且为节点设定颜色类型

    使用gephi过程中出现两个问题: 一.节点编号不安给定的属性(Nodes)编号,而是莫名其妙地从1w+開始 解决:数据列名中需包括 id.则默觉得节点编号 二.怎样在上传的数据中指定节点颜色 须要一 ...

  6. 何时使用static类(工具类)

    一个static类,指所有成员都是static方法构成的.而没有不论什么成员变量, 也称为Utility class 或者Utility Pattern [參考: Utility Pattern].它 ...

  7. 火狐Vimperator插件

    http://www.iplaysoft.com/vimium-and-vimperator.html http://wangbixi.com/x2923/comment-page-1/

  8. CodeForces 596A

    Description After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the ...

  9. Truck History --hdoj

    Truck History Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 131072/65536K (Java/Other) Tota ...

  10. 辨异 —— Java 中的抽象类和接口

    接口优于抽象类.-- <Effective Java>(Item 18) 0. 语法区别 抽象类允许给出某些方法的实现,接口不允许: 为了实现由抽象类定义的类型(type),类必须成为抽象 ...