题目大意:

给定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. 判断是否英文字母或数字的C#正则表达式

    private int IsDigitOrNumber(string str) { if(System.Text.RegularExpressions.Regex.IsMatch(str,@" ...

  2. png图片使用opacity在ie中出现黑边情况

    JQuery动画的淡入淡出效果,用在PNG24的图片上,在IE7.IE8下会出现黑边框. 有些人觉得很奇怪,为什么?潘?E6正常,反而在IE7.8下却有黑边呢. 其实问题出在filter属性上.IE6 ...

  3. SpringBoot+Thymeleaf+iView

    SpringBoot+Thymeleaf参考: https://www.cnblogs.com/kibana/p/10236187.html 1.Controller: package cn.mmwe ...

  4. php常见的验证方法

    php常见的验证方法 干货文章 ·2018-03-16 23:50:36 <?php /** * @param $id * @return false|int * 检测id */ functio ...

  5. 理解 Activity.runOnUiThread

    在开发 Android 应用的时候我们总是要记住应用主线程. 主线程非常繁忙,因为它要处理绘制UI,响应用户的交互,默认情况下执行我们写下的大部分代码. 好的开发者知道他/她需要将重负荷的任务移除到工 ...

  6. 让所有Excel数据格全部乘 某个数

    1  首先设置单元格格式要是数字 2  然后在随便一个单元格写入你要乘的数字 3  粘贴的时候设置选择性粘贴,然后设置乘就OK

  7. CreateFile的内部实现

    今天想看看CreateFile的内部实现,不过网上没有想要的资料,都只是对参数分析了一下.找了找WRK源码,找到CreateFile的源码自己来分析一下. HANDLE WINAPI CreateFi ...

  8. 【CSS】三栏布局的经典实现

    要求:自适应宽度,左右两栏固定宽度,中间栏优先加载: <!DOCTYPE html> <html> <head> <title>layout</t ...

  9. Tomcat 配置访问限制:访问白名单和访问黑名单

    最近公司的阿里云服务器上配置的 Tomcat 服务器运行 java的环境,但是通过观察 Tomcat 这几天的日志发现,有很多莫名其妙的 IP 访问主机下莫名其妙的地址,如:/80./testprox ...

  10. java静态代理及动态代理(学习示例)

    1.接口 public interface Channel { void send(); } 2.实现类(可以为各种不同实现) public class ChannelImpl implements ...