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. Java内存区域与内存溢出异常(JVM学习系列1)

    相对于C.C++等语言来说,Java语言一个很美好的特性就是自动内存管理机制.C语言等在申请堆内存时,需要malloc内存,用完还有手动进行free操作,若程序员忘记回收内存,那这块内存就只能在进程退 ...

  2. Java 必须掌握的 20+ 种 Spring 常用注解

    Spring部分 1.声明bean的注解 @Component 组件,没有明确的角色 @Service 在业务逻辑层使用(service层) @Repository 在数据访问层使用(dao层) @C ...

  3. html5中视频播放问题总结

    html5中视频播放问题总结 文章 1.问题一 框架? 加个标签就OK! <video id="video1" src="/video1.mp4" con ...

  4. python3 error 机器学习 错误

    AttributeError: 'NoneType' object has no attribute 'sqrt' 这个错误其实是因为 plt.scatter(x[:,0],x[:,1],x[:,2] ...

  5. Axure RP 9 Mac正式汉化版安装教程

    Axure RP9 汉化版是mac平台上一款交互式原型设计神器,是专为UX专业人员和业务分析师设计的专业网站原型设计工具!可以帮助他们快速创建应用程序和网站的线框,原型和规格!新功能包括一系列广泛的改 ...

  6. 【题解】Luogu P4867 Gty的二逼妹子序列

    原题传送门 同Luogu P4396 [AHOI2013]作业 询问多了10倍,但还能跑过(smog #include <bits/stdc++.h> #define N 100005 # ...

  7. [c/c++] programming之路(27)、union共用体

    共用体时刻只有一个变量,结构体变量同时并存 一.创建共用体的三种形式 #include<stdio.h> #include<stdlib.h> #include<stri ...

  8. 论文笔记:Siamese Cascaded Region Proposal Networks for Real-Time Visual Tracking

    Siamese Cascaded Region Proposal Networks for Real-Time Visual Tracking 2019-03-20 16:45:23 Paper:ht ...

  9. LeetCode174-Dungeon Game-数组,动态规划

    题目描述 The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dun ...

  10. ModelBiner不验证某个属性

    问题 使用MVC的同学十有八九都会遇到这个错误:从客户端(Content="<script>...")中检测到有潜在危险的Request.Form 值. 这个错误是在请 ...