Swordsman

Time Limit: / MS (Java/Others)    Memory Limit: / K (Java/Others)
Total Submission(s): Accepted Submission(s): Problem Description
Lawson is a magic swordsman with k kinds of magic attributes v1,v2,v3,…,vk. Now Lawson is faced with n monsters and the i-th monster also has k kinds of defensive attributes ai,,ai,,ai,,…,ai,k. If v1≥ai, and v2≥ai, and v3≥ai, and … and vk≥ai,k, Lawson can kill the i-th monster (each monster can be killed for at most one time) and get EXP from the battle, which means vj will increase bi,j for j=,,,…,k.
Now we want to know how many monsters Lawson can kill at most and how much Lawson's magic attributes can be maximized. Input
There are multiple test cases. The first line of input contains an integer T, indicating the number of test cases. For each test case:
The first line has two integers n and k (≤n≤,≤k≤).
The second line has k non-negative integers (initial magic attributes) v1,v2,v3,…,vk.
For the next n lines, the i-th line contains 2k non-negative integers ai,,ai,,ai,,…,ai,k,bi,,bi,,bi,,…,bi,k.
It's guaranteed that all input integers are no more than 109 and vj+∑i=1nbi,j≤109 for j=1,2,3,…,k. It is guaranteed that the sum of all n ≤×.
The input data is very large so fast IO (like `fread`) is recommended. Output
For each test case:
The first line has one integer which means the maximum number of monsters that can be killed by Lawson.
The second line has k integers v′,v′,v′,…,v′k and the i-th integer means maximum of the i-th magic attibute. Sample Input Sample Output Hint For the sample, initial V = [, , ]
① kill monster # (, , ), V + [, , ] = [, , ]
② kill monster # (, , ), V + [, , ] = [, , ]

对于 k 种防御属性,分开进行从小到大排序,设立 k 个指针从最小处开始往最大处移动,对满足被杀死的条件的属 性进行标记

,当某只 monster 的所有防御属性都被标记时,更新剑士的魔法属性同时更新指针往后移动。时间复 杂度 O(kn log n)

#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
struct node{
int val;
int id;
}a[][];
int b[][];
int sum[];
bool cmp(node p,node q)
{
return p.val<q.val;
}
#define fi(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 t;
fi(t);
while(t--)
{
int n,m;
fi(n);
fi(m);
memset(sum,,sizeof sum);
int pq[];
for(int i=;i<=m;i++)
{
fi(pq[i]);
}
for(int i=;i<=n;i++)
{
for(int j=;j<=m;j++)
{
fi(a[j][i].val);
a[j][i].id = i;
}
for(int j=;j<=m;j++)
fi(b[j][i]);
}
for(int i=;i<=m;i++)
sort(a[i]+,a[i]++n,cmp);
int zhizhen[]={,,,,,};
int pppp=;
while()
{
int pp=;
for(int i=;i<=m;i++)
{
while(a[i][zhizhen[i]].val<=pq[i]&&zhizhen[i]<=n)
{ sum[a[i][zhizhen[i]].id]++;
if(sum[a[i][zhizhen[i]].id]==m)
{
pp++;
pppp++;
for(int j=;j<=m;j++)
{
pq[j]+=b[j][a[i][zhizhen[i]].id]; }
}
zhizhen[i]++; }
}
if(pp==)
break; }
cout<<pppp<<endl;
for(int i=;i<=m;i++)
{ if(i!=)
cout<<" ";
cout<<pq[i];
}
cout<<endl; } return ;
}

hdu6396(思维+输入挂)的更多相关文章

  1. 【libreOJ模板】并查集(输入挂,取模与find优化)

    1.了解了各种输入挂性orz,找到了一个合适的 2.find用while写能快一倍,并且能被数据卡掉 3.取模只能快十几毫秒,但也能被数据卡掉 取模find双优化是1997mm过的 再加一个性价比较高 ...

  2. ACM的奇计淫巧_输入挂

    什么是输入挂? 众所周知scanf比cin快的多,那么有没有比scanf更快的东西呢?答案就是输入挂,输入挂利用了告诉读取的函数getchar(),然后再人工处理成整数或浮点,比使用scanf快太多. ...

  3. 【7-9 有重复的数据I (20 分)】【此题卡输入,需要自己写个输入挂】

    参考一个博客的输入挂,先挂在此处,以备以后使用. import java.io.*; import java.util.*; import java.math.*; public class Main ...

  4. [hdu5392 Infoplane in Tina Town]置换的最小循环长度,最小公倍数取模,输入挂

    题意:给一个置换,求最小循环长度对p取模的结果 思路:一个置换可以写成若干循环的乘积,最小循环长度为每个循环长度的最小公倍数.求最小公倍数对p取模的结果可以对每个数因式分解,将最小公倍数表示成质数幂的 ...

  5. HDU6396 (贪心+fread 挂)

    题意:初始值你有k个属性的攻击vi,有n个怪兽,每个怪兽有k种属性的血量ai,并且有k种属性的加成bi,当你的k种属性的值全部大于等于某只怪兽的k种属性的血量,你可以杀死他,并且你的攻击力vi会升级, ...

  6. hdu 6205: card card card【输入挂】

    题目链接 感谢 http://blog.csdn.net/txgang/article/details/77568491 以下供参考 getchar读入法 2683MS FastIO法 MX=1e2 ...

  7. hdu 6044 : Limited Permutation (2017 多校第一场 1012) 【输入挂 组合数学】

    题目链接 参考博客: http://blog.csdn.net/jinglinxiao/article/details/76165353 http://blog.csdn.net/qq_3175920 ...

  8. ACM输入外挂

    一.什么是输入挂 scanf的输入速度不cin快得多,那么有没有比scanf更快的东西呢?这就是要用到输入挂了. 二.什么时候使用输入挂 当输入规模达到1x10^6次方的时候,就需要输入挂,否则很可能 ...

  9. hdu-5992 Finding Hotels(kd-tree)

    题目链接: Finding Hotels Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 102400/102400 K (Java/ ...

随机推荐

  1. 通过浏览器F12开发工具快速获取别的网站前端代码的方法

    通过浏览器F12开发工具快速获取别的网站前端代码的方法 说明:直接另存为网页是比较老的做法,会有很多没用的东西下载下来.通过F12开发工具,sources获取到的是比较好的,有目录结构的源文件.

  2. OO第一单元优化博客

    OO第一单元优化博客 第一次作业: 合并同类项+提正系数项+优化系数指数0/1=满分 第二次作业: 初始想法 一开始是想以\(sin(x)​\)和\(cos(x)​\)的指数作为坐标,在图上画出来就可 ...

  3. IP通信基础的第一个星期

    IP通信基础不仅是很多专业课程的基础,同时学好它,在以后很多工作上都可以运用到,有网络工程师.通信工程师等等,当然,有些证书也会涉及到IP通信基础,有网络中级高级 CCNA等等. 那么,学好IP通信基 ...

  4. windows修改注册表添加开启自启动

    快捷键win+R regedit 计算机\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run 新建字符串值 C:\soft ...

  5. 王之泰《面向对象程序设计(java)》课程学习总结

    第一部分:理论知识学习部分 总复习纲要 1. Java语言特点与开发环境配置(第1章.第2章) 2. Java基本程序结构(第3章) 3. Java面向对象程序结构(第4章.第5章.第6章) 4. 类 ...

  6. blogger添加代码高亮

    blogger(blogspot)自带的是没有代码高亮的,我们可以用下面的方法添加代码高亮. 首先我们打开blogger(blogspot)后台,然后点击主题背景-->修改html,然后在弹出的 ...

  7. JavaScript基础数据类型(一)

    动态类型 JavaScript 是一种弱类型或者说动态语言.这意味着你不用提前声明变量的类型,在程序运行过程中,类型会被自动确定.这也意味着你可以使用同一个变量保存不同类型的数据: var foo = ...

  8. selenium修改cookie

    WebDriver操作cookie的方法:cookie以字典形式保存 get_cookies()     获取所有的cookie get_cookie(name)   返回字典的key为"n ...

  9. Dingo 的安装

    安装Dingo需要下面的环境: Laravel 5.1 或 lumen 5.1 + php 5.59+ 1. 修改composer.json 文件,添加下面的代码: "require&quo ...

  10. Object-C的类可以多重继承吗?可以实现多个接口吗?category是什么?重写一个类的方式用继承好还是分类好,为什么?

    Object-C的类可以多重继承吗?可以实现多个接口吗?category是什么?重写一个类的方式用继承好还是分类好,为什么? 答:Object-c的类不可以多重继承,可以实现多个接口(协议),Cate ...