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

【题意】

在这里输入题意

【题解】

开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. sass基础教程

    1. 使用变量; $highlight-color: #F90; .selected { border: 1px solid $highlight-color; } //编译后 .selected { ...

  2. UI 经常用法总结之--- UIWindow UIView (不断更新中)

     UIWindow (UIView) 1.创建一个uiwindow对象 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScr ...

  3. HDU Distinct Values

    /* 一开始想到的是 对于每个区间操作 先按左端点排序(包含的区间 留这打的区间) 我们维护pos表示 a数组找到了哪 对于当前这个区间 只需要找 pos--r这个区间 用set维护能用的数 没放到a ...

  4. /proc/sysrq-trigger说明【转】

    本文转载自:http://blog.csdn.net/silenttung/article/details/8084136 版权声明:本文为博主原创文章,未经博主允许不得转载. /proc/sysrq ...

  5. Javascript万物皆对象?

    在javascript的世界里,有这么一句话,万物皆对象. 但是这个对象,应该怎么理解呢? exm........??,难道值类型也是对象?!! 当然,不是. 准确地讲是对于“引用类型”而言. 那,在 ...

  6. 关于java1.8中LocalDateTime实现日期,字符串互转小坑。

    今天无聊,来看了下1.8的时间类型LocalDateTime,当想把字符串转成LocalDateTime的时候报错!! java.time.format.DateTimeParseException: ...

  7. Open CASCADE Technology(OCCT)概述

    OCCT模块结构图 基础类: Foundation Classes module underlies all other OCCT classes; 模型数据: Modeling Data modul ...

  8. VirtualBox里如何正确安装增强工具(图文详解)

    不多说,直接上干货! 找到 复制到

  9. .net 对称加密

    后台   public class CryptoHelper     {         // 对称加密算法提供器         private ICryptoTransform encryptor ...

  10. python ansible api

    #!/usr/bin/env python # -*- coding: utf-8 -*- # @File : test2.py # @Author: Anthony.waa # @Date : 20 ...