hdu6396 /// fread()快速读入挂
2024-09-01 11:13:31
题目大意:
给定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 ;
}
最新文章
- js自动提示查询添加功能(不是自动补全)
- Spring和SpringMVC父子容器关系初窥
- plist文件的读取和xib加载cell
- Cocos2dx.3x入门三部曲-Hello Game项目创建(二)
- groovy–运算符重载
- 【转】设计模式(九)外观模式Facade(结构型)
- Android:文件夹显示红色叹号
- java.lang.UnsupportedClassVersionError(java项目版本一致问题)
- Eclipese Mars安装SVN的全步骤
- thymeleaf中的日期格式化
- Spring MVC Ajax 复杂参数的批量传递
- 并发之痛 Thread,Goroutine,Actor
- 通过awk 和 sed 将多余的列剔除
- Java中的回车换行符/n /r /t
- fffmgg
- layout_weight 全解析
- python第四十三课——封装性
- Activity四种启动模式之singleTask应用
- 浅谈为什么一个java源文件中只能有一个public类?
- Eclipse软件使用说明