当前位置:网站首页>“蔚来杯“2022牛客暑期多校训练营7 F
“蔚来杯“2022牛客暑期多校训练营7 F
2022-08-10 19:07:00 【eyuhaobanga】
祖玛游戏,相邻相同可删,相邻之和=x可删
AC代码:
#include <bits/stdc++.h> #define rep(i,a,n) for(int i=a;i<n;i++) using namespace std; using LL = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, x; cin >> n >> x; deque<int> qu; int ans = 0; for (int i = 0; i < n; i++) { int c; cin >> c; if (i != 0) { int z; if (!qu.empty()) { z = qu.back(); } else { qu.push_back(c); continue; } if (z == c or z + c == x) { qu.pop_back(); ans++; } else { qu.push_back(c); } } else { qu.push_back(c); } } int z1, z2; bool ok = true; while (qu.size() >= 2 and ok) { ok = false; z1 = qu.front(), z2 = qu.back(); if (z1 + z2 == x or z1 == z2) { qu.pop_front(); qu.pop_back(); ans++; ok = true; } } cout << ans << '\n'; return 0; }
边栏推荐
- [Natural Language Processing] [Vector Representation] PairSupCon: Pairwise Supervised Contrastive Learning for Sentence Representation
- 怎么完全卸载赛门铁克_Symantec卸载方法,赛门铁克卸载「建议收藏」
- What is the upstream bandwidth and downstream bandwidth of the server?
- 2022 Hangdian Multi-School Seven Black Magic (Sign-in)
- 【Knowledge Sharing】What is SEI in the field of audio and video development?
- uni-app 数据上拉加载更多功能
- When selecting a data destination when creating an offline synchronization node - an error is reported in the table, the database type is adb pg, what should I do?
- 西安凯新(CAS:2408831-65-0)Biotin-PEG4-Acrylamide 特性
- 【SemiDrive源码分析】【MailBox核间通信】52 - DCF Notify 实现原理分析 及 代码实战
- 小分子PEG CAS:1352814-07-3生物素-PEG6-丙酸叔丁酯
猜你喜欢
Introduction to 3 d games beginners essential 】 【 modeling knowledge
30分钟使用百度EasyDL实现健康码/行程码智能识别
Hangdian Multi-School Seven 1003-Counting Stickmen (Combination Mathematics)
uni-app 数据上拉加载更多功能
laya打包发布apk
FEMRL: A Framework for Large-Scale Privacy-Preserving Linkage of Patients’ Electronic Health Rec Paper Summary
优化是一种习惯●出发点是'站在靠近临界'的地方
力扣18-四数之和——双指针法
mysql----group by、where以及聚合函数需要注意事项
【深度学习前沿应用】图像风格迁移
随机推荐
电脑如何去掉u盘写保护的状态
【LeetCode】42、接雨水
GBASE 8s 高可用RSS集群搭建
idea汉化教程[通俗易懂]
“2022零信任神兽方阵”启动调研,欢迎各单位填报信息
巧用RoaringBitMap处理海量数据内存diff问题
3D Game Modeling Learning Route
YOLOv3 SPP源码分析
苹果字体查找
一维数组动态和问题答记
(十)图像数据的序列与反序列化
我们用48h,合作创造了一款Web游戏:Dice Crush,参加国际赛事
杭电多校七 1003-Counting Stickmen(组合数学)
When selecting a data destination when creating an offline synchronization node - an error is reported in the table, the database type is adb pg, what should I do?
IIC通信协议总结[通俗易懂]
【知识分享】在音视频开发领域中SEI到底是个啥?
2020 ICPC Shanghai Site G
力扣18-四数之和——双指针法
MATLAB设计,FPGA实现,联合ISE和Modelsim仿真的FIR滤波器设计
西安凯新(CAS:2408831-65-0)Biotin-PEG4-Acrylamide 特性