当前位置:网站首页>[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;
}
边栏推荐
- MySQL startup options and configuration files
- 【实习经验】Date工具类中添加自己实现的方法
- 13. User web layer services (I)
- 阿里最新股权曝光:软银持股23.9% 蔡崇信持股1.4%
- JWT login expiration - automatic refresh token scheme introduction
- 基于C语言的LR1编译器设计
- Crop the large size image of target detection into a fixed size image
- CARLA 笔记(04)— Client 和 World (创建 Client、连接 World 、批处理对象、设置 Weather、设置 Lights、World snapshots)
- [internship experience] add your own implementation method to the date tool class
- 记账软件如何查看收入支出
猜你喜欢

井贤栋等蚂蚁集团高管不再担任阿里合伙人 确保独立决策

Fifth, download the PC terminal of personality and solve the problem of being unable to open it

What are the benefits of taking NPDP

Interview secrets are widely distributed, and the exclusive secrets of editing, testing and learning are leaked?!
![[C Advanced] pointer array vs array pointer](/img/1e/33f9cc9446dcad8cdb78babbb5a22c.jpg)
[C Advanced] pointer array vs array pointer

使用RecyclerView,实现列表左滑菜单

基于C语言的LR1编译器设计

致尚科技IPO过会:年营收6亿 应收账款账面价值2.7亿

Summary of scaling and coding methods in Feature Engineering

小程序毕设作品之微信校园洗衣小程序毕业设计成品(5)任务书
随机推荐
Thinkphp+ pagoda operation environment realizes scheduled tasks
Various ways to use new
Network packet loss, network delay? This artifact helps you get everything done!
ONNXRuntime【推理框架,用户可以非常便利的用其运行一个onnx模型】
小程序毕设作品之微信校园洗衣小程序毕业设计成品(6)开题答辩PPT
The most complete collection of strategies! Super AI painting tool midjourney open beta! Come and build your fantasy metauniverse
JS module, closure application
Figure 8 shows you how to configure SNMP
软考 系统架构设计师 简明教程 | 软件系统建模
[C Advanced] pointer array vs array pointer
idea Gradle7.0+ :Could not find method compile()
小程序毕设作品之微信校园洗衣小程序毕业设计成品(2)小程序功能
我们要学会查看技术细节点的文档化说明
Fifth, download the PC terminal of personality and solve the problem of being unable to open it
Construction and application of industrial knowledge atlas (I): overview of industrial knowledge atlas
Keras deep learning practice - recommend system data coding
宇宙没有尽头,UTONMOS能否将元宇宙照进现实?
13、用户web层服务(一)
2022ACM夏季集训周报(四)
Summary of scaling and coding methods in Feature Engineering