题目大意:

给定n k

给定主角具有的k种属性

给定n个怪兽具有的k种属性和打死该怪兽后能得到的k种属性对应增幅

求主角最多能打死多少怪兽和最终主角的k种属性

k最大为5 开5个优先队列贪心

快速读入模板

#include <bits/stdc++.h>
using namespace std; #define reads(n) FastIO::read(n)
namespace FastIO {
const int SIZE = << ;
char buf[SIZE], obuf[SIZE], str[];
int bi = SIZE, bn = SIZE, opt;
int read(char *s) {
while (bn) {
for (; bi < bn && buf[bi] <= ' '; bi++);
if (bi < bn) break;
bn = fread(buf, , SIZE, stdin);
bi = ;
}
int sn = ;
while (bn) {
for (; bi < bn && buf[bi] > ' '; bi++) s[sn++] = buf[bi];
if (bi < bn) break;
bn = fread(buf, , SIZE, stdin);
bi = ;
}
s[sn] = ;
return sn;
}
bool read(int& x) {
int n = read(str), bf;
if (!n) return ;
int i = ; if (str[i] == '-') bf = -, i++; else bf = ;
for (x = ; i < n; i++) x = x * + str[i] - '';
if (bf < ) x = -x;
return ;
}
}; int main()
{
int n; reads(n);
return ;
}
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define INF 0x3f3f3f3f
#define mem(i,j) memset(i,j,sizeof(i))
const int N=1e5+; #define reads(n) FastIO::read(n)
namespace FastIO {
const int SIZE = << ;
char buf[SIZE], obuf[SIZE], str[];
int bi = SIZE, bn = SIZE, opt;
int read(char *s) {
while (bn) {
for (; bi < bn && buf[bi] <= ' '; bi++);
if (bi < bn) break;
bn = fread(buf, , SIZE, stdin);
bi = ;
}
int sn = ;
while (bn) {
for (; bi < bn && buf[bi] > ' '; bi++) s[sn++] = buf[bi];
if (bi < bn) break;
bn = fread(buf, , SIZE, stdin);
bi = ;
}
s[sn] = ;
return sn;
}
bool read(int& x) {
int n = read(str), bf;
if (!n) return ;
int i = ; if (str[i] == '-') bf = -, i++; else bf = ;
for (x = ; i < n; i++) x = x * + str[i] - '';
if (bf < ) x = -x;
return ;
}
}; int n,k;
int v[],a[N][];
struct NODE{
int x,id;
bool operator <(const NODE& p)const {
return x>p.x;
}
};
priority_queue<NODE> q[]; int main()
{
int t; reads(t);
while(t--) {
reads(n); reads(k);
for(int i=;i<k;i++)
while(!q[i].empty()) q[i].pop();
for(int i=;i<k;i++)
reads(v[i]);
for(int i=;i<n;i++)
for(int j=;j<*k;j++)
reads(a[i][j]);
for(int i=;i<n;i++)
q[].push({a[i][],i});
int ans=;
while() {
bool OK=;
for(int i=;i<k;i++) {
while(!q[i].empty()) {
NODE t=q[i].top();
if(t.x<=v[i]) {
q[i].pop();
if(i==k-) {
ans++; OK=;
for(int j=;j<k;j++)
v[j]+=a[t.id][j+k];
} else {
t.x=a[t.id][i+];
q[i+].push(t);
}
} else break;
}
}
if(!OK) break;
}
printf("%d\n",ans);
for(int i=;i<k;i++) {
printf("%d",v[i]);
if(i==k-) printf("\n");
else printf(" ");
}
} return ;
}

hdu6396 /// fread()快速读入挂的更多相关文章

  1. fread 快速读入 (神奇挂!)

    注意这里是将后台的所有数据都读入在计算 #include<bits/stdc++.h> using namespace std; #define ll long long namespac ...

  2. fread读入挂and普通读入挂and浮点数读入挂

    fread读入挂 版本一 namespace fastIO { #define BUF_SIZE 100000 //fread -> read bool IOerror = 0; inline ...

  3. 读入挂(IO)

    快如闪电,清华杜瑜皓的读入挂,一模一样代码,加了这个之后... 细思极恐,and 整整行!!! namespace IO{ #define BUF_SIZE 100000 #define OUT_SI ...

  4. 牛客网 牛客练习赛43 C.Tachibana Kanade Loves Review-最小生成树(并查集+Kruskal)+建虚点+读入挂

    链接:https://ac.nowcoder.com/acm/contest/548/C来源:牛客网 Tachibana Kanade Loves Review 时间限制:C/C++ 2秒,其他语言4 ...

  5. HDU 6396 Swordsman --------2018 Multi-University Training Contest 7 (模拟+读入挂)

    原题地址: 打怪升级 一开始有N个怪物:主角有K个能力:只有K个能力都击败怪物才能斩杀怪物并获得K个能力的增值:问最多能杀几个怪物: 做法: 用优先队列把怪物能力装进去:能力小放前面: 最重要的是数据 ...

  6. HDU 6044 Limited Permutation 读入挂+组合数学

    Limited Permutation Problem Description As to a permutation p1,p2,⋯,pn from 1 to n, it is uncomplica ...

  7. HDU 6396 贪心+优先队列+读入挂

    Swordsman Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total ...

  8. 洛谷 P4149 [IOI2011]Race-树分治(点分治,不容斥版)+读入挂-树上求一条路径,权值和等于 K,且边的数量最小

    P4149 [IOI2011]Race 题目描述 给一棵树,每条边有权.求一条简单路径,权值和等于 KK,且边的数量最小. 输入格式 第一行包含两个整数 n, Kn,K. 接下来 n - 1n−1 行 ...

  9. 洛谷 P2634 [国家集训队]聪聪可可-树分治(点分治,容斥版) +读入挂+手动O2优化吸点氧才过。。。-树上路径为3的倍数的路径数量

    P2634 [国家集训队]聪聪可可 题目描述 聪聪和可可是兄弟俩,他们俩经常为了一些琐事打起来,例如家中只剩下最后一根冰棍而两人都想吃.两个人都想玩儿电脑(可是他们家只有一台电脑)……遇到这种问题,一 ...

随机推荐

  1. Cocos2d-x的Android配置以及相关参考文档

    关于Win7下配置Coco2d-x的Android开发环境,可以参考子龙山人的博客:Setting Up Cocos2d-x Android Development on Win7,这篇文章写得很详细 ...

  2. LLppdd has a dream!

    LLppdd has a dream Time Limit: 3 s Memory Limit: 256 MB 题目背景 LLppdd经过他充满坎坷的初三后,他的成绩也充满了坎坷. 临近中考了,他希望 ...

  3. 博客中引入了gitment评论系统

    官方github地址:https://github.com/imsun/gitment 官方中文说明地址:https://imsun.net/posts/gitment-introduction/ 官 ...

  4. myeclipse中使用maven插件的时候,报错-Dmaven.multiModuleProjectDirectory system propery is not set.

    -Dmaven.multiModuleProjectDirectory system propery is not set. Check $M2_HOME environment variable a ...

  5. nodejs 进阶:图片裁剪

    demo 图片: 效果: var fs = require('fs'); var gm = require('gm'); gm("./不饿.jpg").crop(100,100,2 ...

  6. go类c语法

    go类c语法 一般来说,如果一门语言具有类c语法,意味着当你习惯使用其他类c语言例如c.c++.java.javascript和c#,然后你就会发现go语言和它们也类似,至少表面上是.例如,使用&am ...

  7. Linux系统上安装MySQL 5.5prm

    http://www.cnblogs.com/sunson/articles/2172086.html

  8. PHP ftp_fget() 函数

    定义和用法 ftp_fget() 函数从 FTP 服务器上下载一个文件并保存到本地一个已经打开的文件中. 如果成功,该函数返回 TRUE.如果失败,则返回 FALSE. 语法 ftp_fget(ftp ...

  9. Work 4(通知类) (2019.04.25)

  10. 单调栈+线段树——cf1220F

     首先考虑初始排列,pi会让周围所有比其大的元素深度+1,所以要求每个点的深度,只要其被覆盖了几次即可 这个覆盖可以通过处理每个元素的左右边界(单调栈O(n))+线段树区间更新(Ologn(n))来做 ...