题目大意:
给定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 ;
}