当前位置:网站首页>[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;
}
边栏推荐
- 13、用户web层服务(一)
- Install the wireless network card driver
- There is no need for semantic segmentation of annotation data! Eth & Leuven University proposed maskdistill, using transformer for unsupervised semantic segmentation, SOTA
- Matlab digital image processing experiment 2: single pixel spatial image enhancement
- 软考 系统架构设计师 简明教程 | 系统设计
- 用命令如何返回上级目录
- 软考 系统架构设计师 简明教程 | 软件系统建模
- Accuracy improvement method: efficient visual transformer framework of adaptive tokens (open source)
- 【idea】设置提取serialVersionUID
- 小程序毕设作品之微信校园洗衣小程序毕业设计成品(2)小程序功能
猜你喜欢

NoSQL —— NoSQL 三大理论基石 —— CAP —— BASE—— 最终一致性

小程序毕设作品之微信校园洗衣小程序毕业设计成品(1)开发概要

基于C语言实现线性表的建立、插入、删除、查找等基本操作

Realize the basic operations such as the establishment, insertion, deletion and search of linear tables based on C language

达科为生物IPO过会:年营收8.37亿 吴庆军父女为实控人

西测测试深交所上市:年营收2.4亿募资9亿 市值47亿

SQL tutorial: introduction to SQL aggregate functions

Image features and extraction

Dat.gui control custom placement and dragging

Redis cluster setup - use docker to quickly build a test redis cluster
随机推荐
SwiftUI 地图大全之 使用 MapKit 进行搜索
Image features and extraction
[training day3] section [greed] [two points]
看看有没有你,各赛区入围名单
利用C语言实现URL解析的基本方法之优秀
软考 系统架构设计师 简明教程 | 软件系统建模
egg-swagger-doc 图形验证码解决方案
The finished product of wechat campus laundry applet graduation design (1) development outline
【LeetCode】592. 分数加减运算
Hcip - OSPF comprehensive experiment
opencv图像的缩放平移及旋转
GoPro接入 - 根据GoPro官方文档/Demo,实现对GoPro的控制和预览
There is no need for semantic segmentation of annotation data! Eth & Leuven University proposed maskdistill, using transformer for unsupervised semantic segmentation, SOTA
[luogu_p4556] [Vani has an appointment] tail in rainy days / [template] segment tree merging
JS 模块、闭包应用
Wechat campus laundry applet graduation design finished product (4) opening report
Jianzhi offer 07 rebuild binary tree -- construct binary tree from middle order and post order traversal sequence
Browser kernel module composition
Keras深度学习实战——推荐系统数据编码
Install redis and graphical client under MacOS