题目链接:https://ac.nowcoder.com/acm/contest/886/J

题目大意

  略。

分析

  见代码。

代码如下

 #include <bits/stdc++.h>
using namespace std; #define INIT() ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define Rep(i,n) for (int i = 0; i < (n); ++i)
#define For(i,s,t) for (int i = (s); i <= (t); ++i)
#define rFor(i,t,s) for (int i = (t); i >= (s); --i)
#define ForLL(i, s, t) for (LL i = LL(s); i <= LL(t); ++i)
#define rForLL(i, t, s) for (LL i = LL(t); i >= LL(s); --i)
#define foreach(i,c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define rforeach(i,c) for (__typeof(c.rbegin()) i = c.rbegin(); i != c.rend(); ++i) #define pr(x) cout << #x << " = " << x << " "
#define prln(x) cout << #x << " = " << x << endl #define LOWBIT(x) ((x)&(-x)) #define ALL(x) x.begin(),x.end()
#define INS(x) inserter(x,x.begin())
#define UNIQUE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define REMOVE(x, c) x.erase(remove(x.begin(), x.end(), c), x.end()); // ?? x ?????? c
#define TOLOWER(x) transform(x.begin(), x.end(), x.begin(),::tolower);
#define TOUPPER(x) transform(x.begin(), x.end(), x.begin(),::toupper); #define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,inf,sizeof(a))
#define msM(a) memset(a,-1,sizeof(a)) #define MP make_pair
#define PB push_back
#define ft first
#define sd second template<typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &p) {
in >> p.first >> p.second;
return in;
} template<typename T>
istream &operator>>(istream &in, vector<T> &v) {
for (auto &x: v)
in >> x;
return in;
} template<typename T>
ostream &operator<<(ostream &out, vector<T> &v) {
Rep(i, v.size()) out << v[i] << " \n"[i == v.size()];
return out;
} template<typename T1, typename T2>
ostream &operator<<(ostream &out, const std::pair<T1, T2> &p) {
out << "[" << p.first << ", " << p.second << "]" << "\n";
return out;
} inline int gc(){
static const int BUF = 1e7;
static char buf[BUF], *bg = buf + BUF, *ed = bg; if(bg == ed) fread(bg = buf, , BUF, stdin);
return *bg++;
} inline int ri(){
int x = , f = , c = gc();
for(; c<||c>; f = c=='-'?-:f, c=gc());
for(; c>&&c<; x = x* + c - , c=gc());
return x*f;
} template<class T>
inline string toString(T x) {
ostringstream sout;
sout << x;
return sout.str();
} inline int toInt(string s) {
int v;
istringstream sin(s);
sin >> v;
return v;
} //min <= aim <= max
template<typename T>
inline bool BETWEEN(const T aim, const T min, const T max) {
return min <= aim && aim <= max;
} typedef long long LL;
typedef unsigned long long uLL;
typedef pair< double, double > PDD;
typedef pair< int, int > PII;
typedef pair< int, PII > PIPII;
typedef pair< string, int > PSI;
typedef pair< int, PSI > PIPSI;
typedef set< int > SI;
typedef set< PII > SPII;
typedef vector< int > VI;
typedef vector< double > VD;
typedef vector< VI > VVI;
typedef vector< SI > VSI;
typedef vector< PII > VPII;
typedef map< int, int > MII;
typedef map< int, string > MIS;
typedef map< int, PII > MIPII;
typedef map< PII, int > MPIII;
typedef map< string, int > MSI;
typedef map< string, string > MSS;
typedef map< PII, string > MPIIS;
typedef map< PII, PII > MPIIPII;
typedef multimap< int, int > MMII;
typedef multimap< string, int > MMSI;
//typedef unordered_map< int, int > uMII;
typedef pair< LL, LL > PLL;
typedef vector< LL > VL;
typedef vector< VL > VVL;
typedef priority_queue< int > PQIMax;
typedef priority_queue< int, VI, greater< int > > PQIMin;
const double EPS = 1e-;
const LL inf = 0x7fffffff;
const LL infLL = 0x7fffffffffffffffLL;
const LL mod = 1e9 + ;
const int maxN = 1e3 + ;
const LL ONE = ;
const LL evenBits = 0xaaaaaaaaaaaaaaaa;
const LL oddBits = 0x5555555555555555; int T, N, M, c[maxN][maxN], d[maxN];
LL ans;
// dp[i][j]表示 i 号武器,从等级 j - 1开始能获得的最大收益
// dp[i][j] = max(dp[i][j + 1] + c[i][j - 1], 0)
LL dp[maxN][maxN]; // preSum[i] 表示所有武器升到 i 级所能获得的基础分
LL preSum[maxN]; int main(){
//freopen("MyOutput.txt","w",stdout);
//freopen("input.txt","r",stdin);
INIT();
cin >> T;
For(cases, , T) {
ans = ;
ms0(preSum); cin >> N >> M;
For(i, , N) {
For(j, , M) {
cin >> c[i][j];
c[i][j] = -c[i][j];
preSum[j] += c[i][j];
}
dp[i][M] = max(, c[i][M]);
} For(j, , M) {
cin >> d[j];
preSum[j] += d[j] + preSum[j - ];
} For(i, , N) {
rFor(j, M - , ) {
dp[i][j] = max((LL), c[i][j] + dp[i][j + ]);
}
} // 枚举所有武器最低等级
For(j, , M) {
LL sum = preSum[j], minS = infLL; For(i, , N) {
sum += dp[i][j + ];
minS = min(minS, dp[i][j + ]);
}
sum -= minS; // 让收益最低的武器成为短板 ans = max(ans, sum);
} cout << "Case #" << cases << ": " << ans << endl;
}
return ;
}

2019 牛客多校第六场 J Upgrading Technology的更多相关文章

  1. 牛客多校第六场 J Upgrading Technology dp

    题意: 有n个技能,一开始都是0级,第i个技能从j-1级升到j级,花费$c_{i,j}$,但是花费不一定是正的 所有的技能升到j级时,奖励$d_j$但是奖励也不一定是正的 题解: 用sum[i][j] ...

  2. 牛客多校第六场 J Heritage of skywalkert 随即互质概率 nth_element(求最大多少项模板)

    链接:https://www.nowcoder.com/acm/contest/144/J来源:牛客网 skywalkert, the new legend of Beihang University ...

  3. 2019牛客多校第六场 B - Shorten IPv6 Address 模拟

    B - Shorten IPv6 Address 题意 给你\(128\)位的二进制,转换为十六进制. 每\(4\)位十六进制分为\(1\)组,每两组用一个\(":"\)分开. 每 ...

  4. [题解]Shorten IPv6 Address-模拟(2019牛客多校第六场B题)

    题目链接:https://ac.nowcoder.com/acm/contest/886/B 题意: 您将获得一个IPv6地址,该地址是128位二进制字符串.请根据以下规则确定其最短的表示: 以十六进 ...

  5. 2019牛客多校第六场J-Upgrading Technology(枚举+单调队列)

    Upgrading Technology 题目传送门 解题思路 对于这题,我们可以枚举一个k从0~m,表示当前我们把所有技能最少升到了k级,且至少有一个为k级. 此时我们刚好获得了前k个d[]的收益, ...

  6. 2019 牛客多校第六场 D Move

    题目链接:https://ac.nowcoder.com/acm/contest/886/D 题解摘自官方题解 题目大意 有 K 个体积相同的箱子,有 N 个体积相同或相异的物品,现要按照如下策略装箱 ...

  7. 2019 牛客多校第六场 B Shorten IPv6 Address

    题目链接:https://ac.nowcoder.com/acm/contest/886/B 题目大意 给定一个 128 位的二进制 ip 地址,让你以 16 位一组,每组转成 16 进制,用冒号连接 ...

  8. 2019牛客多校第六场H Pair(数位DP 多个数相关)题解

    题意: 传送门 给你\(A,B,C\),要求你给出有多少对\((x, y)\)满足\(x\in [1,A],y\in [1,B]\),且满足以下任意一个条件:\(x \& y > C\) ...

  9. 2019牛客多校第四场J free——分层图&&最短路

    题意 一张无向图,每条边有权值,可以选择不超过 $k$ 条路使其权值变成0,求 $S$ 到 $T$ 的最短路.(同洛谷 P4568) 分析 首先,分层图最短路可以有效解决这种带有 「阶段性」的最短路, ...

随机推荐

  1. Android API Levels 详解

    Android API Levels 当你开发你的Android应用程序时,了解该平台API变更管理的基本方法和概念是很有帮助的.同样的,知道API级别标识以及该标识如何保障你的应用与实际硬件设备相兼 ...

  2. Android_开发片段(Part 2)

    1.List和Map知识: 1)如何定义 List<Map<String,Object>> list=new ArrayList<Map<String,Object ...

  3. 入门级_Tensorflow网络搭建

    Tensorflow如何搭建神经网络 1.基本概念 基于Tensorflow的神经网络:用张量表示数据,用计算图搭建神经网络,用会话执行计算图,优化线上的权重(参数),得到模型 张量:张量就是多维数据 ...

  4. 【SQL】语句/函数汇总

    1.CHARINDEX(短字符A,长字符B) 说明:返回A在B的位置,从1开始,若B中不存在A,则为0 例如: SELECT CHARINDEX('aaaa','abaaaacded')  ----- ...

  5. 前台处理ajax:axios

    """ 1.安装axios cnpm install axios --save 2.src/main.js配置 // 允许ajax发送请求时附带cookie axios. ...

  6. Unity5.2.1上Android真机调试环境配置

    下载SDK,JDK安装,配置JAVA环境 1.下载SDK,下载adt-bundle-windows-x86_64-20131030.zip,下载地址:http://pan.baidu.com/shar ...

  7. JAVA求回文数

    Manacher算法(马拉车算法)时间复杂度O(n) 用过中心检测法(就是上面说的O(n2) O(n^2)O(n )的算法)的都知道对于奇数回文串和偶数回文串的处理是不同的,奇数回文串有2n+1 2n ...

  8. Java传输对象模式

    当我们想要在客户端到服务器的一个传递具有多个属性的数据时,可使用传输对象模式.传输对象也称为值对象.传输对象是一个具有getter/setter方法的简单POJO类,并且是可序列化的,因此可以通过网络 ...

  9. Samcompu Loves Water

    题目背景 Samcompu拥有大量的"水"资源!! 题目描述 Samcompu需要制定一个水计划.这个计划的主要目的就是为了避开老师监视的时间来水. 老师在中途会离开机房T次,第i ...

  10. android项目各个文件详解

    res目录说明 android应用的res目录是一个特殊的目录,该项目里存放了 android应用所用的全部资源,包括图片资源.字符串资源. 颜色资源.尺寸资源等. /res/value/string ...