当前位置:网站首页>[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;
}
边栏推荐
- SwiftUI 地图大全之 使用 MapKit 进行搜索
- Gray histogram
- The finished product of wechat campus laundry applet graduation design (1) development outline
- Zoom, translation and rotation of OpenCV image
- 阿里最新股权曝光:软银持股23.9% 蔡崇信持股1.4%
- Wechat campus laundry applet graduation design finished product (7) Interim inspection report
- Travel notes from July 11 to August 1, 2022
- SQL教程之 SQL 聚合函数入门教程
- Creation and destruction of "C language" function stack frame -- (internal skill)
- Matlab digital image processing experiment 2: single pixel spatial image enhancement
猜你喜欢

Wechat campus laundry applet graduation design finished product (7) Interim inspection report

致尚科技IPO过会:年营收6亿 应收账款账面价值2.7亿
idea Gradle7.0+ :Could not find method compile()

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

List map basic notes
![[luogu_p4556] [Vani has an appointment] tail in rainy days / [template] segment tree merging](/img/e3/c2b3d45c6a0d1f7ff0b8b7bccf2106.png)
[luogu_p4556] [Vani has an appointment] tail in rainy days / [template] segment tree merging

Oppo self-developed large-scale knowledge map and its application in digital intelligence engineering

opencv图像的缩放平移及旋转

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

基于STM32的自由度云台运动姿态控制系统
随机推荐
RSS tutorial: aggregate your own information collection channels, rshub, freshrss, NetNewsWire
Accuracy improvement method: efficient visual transformer framework of adaptive tokens (open source)
Hcip - OSPF comprehensive experiment
What are the benefits of taking NPDP
Oppo self-developed large-scale knowledge map and its application in digital intelligence engineering
See if you are on the shortlist of each division
2022ACM夏季集训周报(四)
Cesium region clipping, local rendering
小程序毕设作品之微信校园洗衣小程序毕业设计成品(1)开发概要
基于C语言实现线性表的建立、插入、删除、查找等基本操作
Redis implements the browsing history module
记账软件如何查看收入支出
宇宙没有尽头,UTONMOS能否将元宇宙照进现实?
Gains and losses of desensitization project
小程序毕设作品之微信校园洗衣小程序毕业设计成品(4)开题报告
A Keypoint-based Global Association Network for Lane Detection
Creation and destruction of "C language" function stack frame -- (internal skill)
Wechat campus laundry applet graduation design finished product of applet completion work (8) graduation design thesis template
利用C语言实现URL解析的基本方法之优秀
MySQL high availability practical solution MHA