当前位置:网站首页>[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;
}
边栏推荐
- 【实习经验】Date工具类中添加自己实现的方法
- Cesium region clipping, local rendering
- In the "meta cosmic space", utonmos will open the digital world of the combination of virtual and real
- Gray histogram
- 【2022-07-25】
- 【2022-07-25】
- Charles tutorial
- English grammar_ Definite article the_ Small details
- Software testing system architecture designer concise tutorial | software testing
- 期货开户的条件和流程
猜你喜欢

13、用户web层服务(一)

Matlab digital image processing experiment 2: single pixel spatial image enhancement

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

Keras deep learning practice - recommend system data coding
![Deep confidence network (DBN) [the classical DBN network structure is a deep neural network composed of several layers of RBM (restricted Boltzmann machine) and one layer of BP]](/img/24/99365deea3a74b7c50aa44abbe7cde.png)
Deep confidence network (DBN) [the classical DBN network structure is a deep neural network composed of several layers of RBM (restricted Boltzmann machine) and one layer of BP]

In the "meta cosmic space", utonmos will open the digital world of the combination of virtual and real

基于STM32的自由度云台运动姿态控制系统

Use recyclerview to realize the left sliding menu of the list

期货手续费标准和保证金比例

Oppo self-developed large-scale knowledge map and its application in digital intelligence engineering
随机推荐
Wechat campus laundry applet graduation design finished product (7) Interim inspection report
Crop the large size image of target detection into a fixed size image
redis集群搭建-使用docker快速搭建一个测试redis集群
关于max做动画的一些关键信息(shift+v)
Jianzhi offer 07 rebuild binary tree -- construct binary tree from middle order and post order traversal sequence
Egg swagger doc graphic verification code solution
SNMP (Simple Network Management Protocol)
在“元宇宙空间”UTONMOS将打开虚实结合的数字世界
[training day3] reconstruction of roads [SPFA]
2022ACM夏季集训周报(四)
小程序毕设作品之微信校园洗衣小程序毕业设计成品(7)中期检查报告
井贤栋等蚂蚁集团高管不再担任阿里合伙人 确保独立决策
The finished product of wechat campus laundry applet graduation design (1) development outline
idea Gradle7.0+ :Could not find method compile()
Software testing system architecture designer concise tutorial | software testing
Motion attitude control system of DOF pan tilt based on stm32
Wechat campus laundry applet graduation design finished product (6) opening defense ppt
Accuracy improvement method: efficient visual transformer framework of adaptive tokens (open source)
VSCode -- 创建模板文件
MySQL高可用实战方案——MHA