当前位置:网站首页>[training day4] card game [greed]
[training day4] card game [greed]
2022-07-27 13:58:00 【VL——MOESR】

Ideas :
We found that , If you want to play defense cards , It must be all knocked out
So two strategies , A defense card , A non fight
Among them, playing cards that are a little bigger than defense cards is definitely the best
Then subtract the attack cards from the sum
c o d e code code
#include<iostream>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const ll MAXN = 1e6 + 10;
ll n, m;
ll a[MAXN], b[MAXN], c[MAXN];
bool v[MAXN];
ll D() {
ll i = m, j = 1, ans = 0;
while(b[j] <= a[i] && i >= 1 && j <= b[0]) {
ans += a[i] - b[j];
i --, j ++;
}
return ans;
}
ll F() {
ll j = 1;
for(ll i = 1; i <= c[0]; i ++) {
while(a[j] <= c[i] && j <= m) j ++;
if(j > m) return 0;
v[j] = 1;
j ++;
}
j = 1;
for(ll i = 1; i <= b[0]; i ++) {
while(((a[j] < b[i]) || (v[j] == 1) ) && j <= m) j ++;
if(j > m) return 0;
j ++;
}
ll ans=0;
for(ll i = 1; i <= m; i ++) ans += v[i] ? 0 : a[i];
for(ll i = 1; i <= b[0]; i ++) ans -= b[i];
return ans;
}
int main() {
scanf("%lld%lld", &n, &m);
string s;
for(ll i = 1; i <= n; i ++) {
cin>>s;
if(s == "ATK") b[0] ++, scanf("%lld", &b[b[0]]);
else c[0] ++, scanf("%lld", &c[c[0]]);
}
for(ll i = 1; i <= m; i ++) scanf("%lld", &a[i]);
sort(a + 1, a + 1 + m);
sort(b + 1, b + 1 + b[0]);
sort(c + 1, c + 1 + c[0]);
printf("%lld", max(D(), F()));
return 0;
}
边栏推荐
- For.. of can be used to traverse which data
- Matlab digital image processing experiment 2: single pixel spatial image enhancement
- 【图论】负环
- Leetcode Tencent selected exercises 50 questions -059. Spiral matrix II
- 关于max做动画的一些关键信息(shift+v)
- WPF visifire.charts4.6.1 tutorial with source code
- MySQL高可用实战方案——MHA
- ONNXRuntime【推理框架,用户可以非常便利的用其运行一个onnx模型】
- Motion attitude control system of DOF pan tilt based on stm32
- idea Gradle7.0+ :Could not find method compile()
猜你喜欢

在灯塔工厂点亮5G,宁德时代抢先探路中国智造

期货公司开户后续会有哪些服务?

记账软件如何查看收入支出

小程序毕设作品之微信校园洗衣小程序毕业设计成品(6)开题答辩PPT

Wechat campus laundry applet graduation design finished product (6) opening defense ppt

我们要学会查看技术细节点的文档化说明

redis集群搭建-使用docker快速搭建一个测试redis集群
![[internship experience] add your own implementation method to the date tool class](/img/56/54c5f62438a627c96f8b4ad06ba863.jpg)
[internship experience] add your own implementation method to the date tool class

小程序毕设作品之微信校园洗衣小程序毕业设计成品(8)毕业设计论文模板

Summary of scaling and coding methods in Feature Engineering
随机推荐
Design of network abnormal traffic analysis system
不需要标注数据的语义分割!ETH&鲁汶大学提出MaskDistill,用Transformer来进行无监督语义分割,SOTA!...
UTNet 用于医学图像分割的混合Transformer
Huiliang technology app is a good place to go to sea: after more than ten years of popularity, why should the United States still choose to go to sea for gold
宇宙没有尽头,UTONMOS能否将元宇宙照进现实?
Chapter3 data analysis of the U.S. general election gold offering project
LeetCode报错及其解决方案
Fifth, download the PC terminal of personality and solve the problem of being unable to open it
Various ways to use new
我们要学会查看技术细节点的文档化说明
VSCode -- 创建模板文件
How to test and decrypt the encryption interface
[daily question] 1206. Design jump table
基于C语言实现线性表的建立、插入、删除、查找等基本操作
Design of LR1 compiler based on C language
We should learn to check the documented instructions of technical details
井贤栋等蚂蚁集团高管不再担任阿里合伙人 确保独立决策
16 VMware horizon 2203 virtual desktop-win10 automatic desktop pool full clone dedicated (XVI)
【idea】设置提取serialVersionUID
Real image denoising based on multi-scale residual dense blocks and block connected cascaded u-net