Alphabetic Removals(思维+模拟)

一个响应ping包延迟偏大的问题 前段时间客户反馈一个使用pc上的命令行ping无线设备(WiFi4)时,设备平均响应时间(测试时长2小时,1秒Ping一次)相比其它机型偏慢的问题,并上传上具体的时间的Log.从log中看到,大多数包的响应还是比较快的,只是个别响应时间较长,且响应时间长的包时间几乎都是一样的100多ms.如下是部分响应时间截图. 整个2小时的测试时间里,总是时不时的出这么上102,104ms的响应时间,这直接导致了平均响应时间被拉大.于是本地测试,也发现了类似的延迟.本地测试时,现象略有... 阅读详情

Alphabetic Removals

You are given a string s consisting of n lowercase Latin letters. Polycarp wants to remove exactly k characters (k≤n) from the string s. Polycarp uses the following algorithm k

times:

if there is at least one letter 'a', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;
if there is at least one letter 'b', remove the leftmost occurrence and stop the algorithm, otherwise go to next item;
...
remove the leftmost occurrence of the letter 'z' and stop the algorithm.

This algorithm removes a single letter from the string. Polycarp performs this algorithm exactly k
times, thus removing exactly k

characters.

Help Polycarp find the resulting string.

Input

The first line of input contains two integers n

and k (1≤k≤n≤4⋅105

) — the length of the string and the number of letters Polycarp will remove.

The second line contains the string s
consisting of n

lowercase Latin letters.

Output

Print the string that will be obtained from s

after Polycarp removes exactly k letters using the above algorithm k

times.

If the resulting string is empty, print nothing. It is allowed to print nothing or an empty line (line break).

Examples
Input

15 3
cccaabababaccbc

Output

cccbbabaccbc

Input

15 9
cccaabababaccbc

Output

cccccc

Input

1 1
u

Output
题意:

给了n和k,然后输入一个长度为n的字符串,然后有k次操作,从字符串中依次按abcd…的顺序删除字符,最后输出k次操作后的字符串。

外面的循环用来标记26个英文字母,里面的循环用来遍历字符串,然后就是按照题意那样删除字符了,删除记为0,输出的时候不输出0即可。

code:

#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int main(){
    int n,k;
    string str;
    cin >> n >> k;
    cin >> str;
    for(int i = 0; i < 26; i++){
        for(int j = 0; j < n && k; j++){
            if(str[j] == 'a' + i){
                str[j] = '0';
                k--;
            }   
        }
    }
    for(int i = 0; i < n; i++){
        if(str[i] != '0') cout << str[i];
    }
    cout << endl;
    return 0;
}
【数字孪生与仿真技术】06:航天器系统建模与验证全流程实战:从多学科建模到数字孪生(附完整代码与工业案例) 摘要:航天器系统开发面临多学科耦合强、验证流程复杂、可靠性要求极高的挑战。本文基于MATLAB/Simulink平台,系统阐述航天器从多域建模、动力系统开发到任务验证的全流程技术框架。内容涵盖Modelica统一建模规范、光伏-电池联合供电系统仿真、基于模型的需求追溯方法、蒙特卡洛可靠性分析及硬件在环测试等核心技术,并结合James Webb太空望远镜电力系统案例,展示工业级应用实践。文中提供完整的Simulink模型代码、仿真结果及流程图,最后探讨数字孪生与AI增强技术在航天器在轨运维中的未来应用。 阅读详情

相关推荐

深入解析Android Thermal框架:从应用层到驱动层的温度管理机制

本文深入解析Android Thermal框架的温度管理机制,从应用层到驱动层详细介绍了温度监测、热状态评估和降温策略执行的全过程。通过分层架构解析和关键组件交互,帮助开发者理解Android设备如何实现高效的温度控制,确保硬件安全并优化性能。

weixin_29303701的博客 256

【题解】Building Strings Gym - 102152E

【题面】 You are given a string s of length n consisting of lowercase English letters. This string can be used to build other strings. The cost of each letter in s is given by another string c of length n consisting of digits, such that the cost of using ...

深蓝旭的博客 796

从解压到编译:手把手带你用TeXstudio搞定第一篇ACM LaTeX论文

本文详细指导如何使用TeXstudio从解压ACM LaTeX模板到成功编译第一篇学术论文的全过程。涵盖环境准备、模板配置、TeXstudio设置及常见问题排查,特别针对ACM会议论文格式要求,帮助学术新人快速掌握LaTeX写作技巧。

weixin_30655569的博客 254

CodeForces - 999C Alphabetic Removals -

output standard output You are given a string ss consisting of nn lowercase Latin letters. Polycarp wants to remove exactly kk characters (k≤nk≤n) from the string ss. Polycarp uses the following alg...

Sean 436

知识图谱本体建模之RDF、RDFS、OWL详解

(一)知识图谱本体建模之RDF、RDFS、OWL详解 1.语义网体系 知识图谱于2012年由Google提出,并不是新概念,而是由语义网络(Semantic Network)衍生而来。语义网络由相互连接的节点和边组成,节点表示概念或者对象,边表示他们之间的关系。RDF,RDFS与OWL都是基于语义网的知识表示框架,在节点和边的取值上做了约束,制定了统一标准,为多源数据的融合提供了便利。RDF,RDFS/OWL 属于语义网技术栈,它们的提出,使得语义网克服了语义网络的缺点。其语义网技术栈如下所示。 2.RD

周周的专栏 1万+

时序约束实战:从setup/hold到时钟路径约束的深度解析

本文深度解析数字设计中的时序约束实战,重点探讨如何从setup/hold检查的核心原理出发,理解并应用时钟路径约束。文章通过剖析Path Requirement的计算逻辑,结合同频、倍频及异步时钟域等典型场景,提供了从解读时序报告到编写、调试SDC约束的系统方法,帮助工程师有效应对复杂SoC设计中的时序收敛挑战。

weixin_29291185的博客 105

C - Alphabetic Removals

题目链接: You are given a stringssconsisting ofnnlowercase Latin letters. Polycarp wants to remove exactlykkcharacters (k≤nk≤n) from the stringss. Polycarp uses the following...

diaomeijiao3430的博客 242

多目标进化算法——NSGA-II(python实现)

NSGA-II(python实现)--最全注释,痴呆能懂--

no___good的博客 5279

Codeforces 888C:K-Dominant Character

题目链接K-Dominant CharacterTime limit:2 seconds Memory limit:256 megabytes Problem DescriptionYou are given a string s consisting of lowercase Latin letters. Character c is called k-dominant iff each sub

并非所有流浪者都迷失了自我 1609

MongoDB分布式事务实现:两阶段提交、日志复制与冲突解决

MongoDB分布式事务机制解析 本文深入剖析了MongoDB 4.0+版本的分布式事务实现原理,重点分析了其在跨文档/跨集合/跨分片场景下的数据一致性解决方案。核心内容包括: 底层机制:采用改进的两阶段提交协议,通过oplog日志复制实现无中心协调器的事务管理,结合WiredTiger存储引擎和锁机制保障ACID特性。 创新设计:将传统2PC的中心协调功能分散到Primary节点,利用oplog作为事务状态记录,实现自动故障恢复和60秒超时回滚机制。 性能优化:针对大事务、写冲突等常见问题,提出拆分微事务

数据知道的博客 1261

AI 视觉宠物喂食器:智能识别 + 精准投喂,打造宠物喂养新体验

AI 视觉宠物喂食器将边缘 AI 计算与传统硬件结合,既解决了传统喂食器的核心痛点,又兼顾了 DIY 的易用性和扩展性。无论是宠物主人 DIY 使用,还是小型创客团队产品化,该方案都具备较高的实用价值和落地性,为宠物智能化喂养提供了轻量化的实现路径。

weixin_42300449的博客 416

CodeForces A. Letters Cyclic Shift【字符串】

A. Letters Cyclic Shift time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given a non-empty string s c

所谓梦想,就是永不停息的疯狂。。。。。 1810

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

[Codeforces]Codeforces Round #490 (Div. 3)

Mishka and Contest #pragma comment(linker, "/STACK:102400000,102400000") #ifndef ONLINE_JUDGE #include "stdafx.h" #else #include<bits/stdc++.h> #endif using namespace std; typedef lo...

weixin_30375427的博客 156

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

You're given a string of lower-case Latin letters. Your task is to find the length of its longest su

C - You're Given a String...  代码:import java.util.Arrays;import java.util.Scanner;public class Main {public static void main(String[] args){  int count=1,k=0,max=0,i=0;  int[] sum=new int[100];  Sca...

L427630的博客 3367

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

String Typing(字符串操作)

You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard. Initially, you have an empty string. Until you type the whole string, you may perfo...

好吗好的~的技术博客 2245

Alphabetic Removals

问题描述:You are given a string ss consisting of nn lowercase Latin letters. Polycarp wants to remove exactly kk characters (k≤nk≤n) from the string ss. Polycarp uses the following algorithm kk times:if t...

someng的博客 340

C. Alphabetic Removals

http://codeforces.com/contest/999/problem/C 给n个字母,删掉k个, 从a开始删,删完了a再开始删b ,一直到z, 输出剩下的字符 import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { ...

美丽的大黄人 381

Diverse Substring(CF-1037A)

Problem Description You are given a string s, consisting of nn lowercase Latin letters. A substring of string s is a continuous segment of letters from ss. For example, "defor" is a substring of "c...

Alex_McAvoy的博客 951

A. Mike and palindrome

time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Mike has a string s consisting of only lowercase English letters

无知的我 1982

999C - Alphabetic Removals

C. Alphabetic Removalstime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou are given a string ss consisting of nn lowercase Latin letters. Polycarp...

memory_qianxiao的博客 804

CodeForces - 999C Alphabetic Removals

C - Alphabetic RemovalsYou are given a stringsconsisting ofnlowercase Latin letters. Polycarp wants to remove exactlykcharacters (k≤n≤n) from the strings. Polycarp uses t...

weixin_38170829的博客 209

Alphabetic Removals(CodeForces - 999C )

You are given a string ss consisting of nn lowercase Latin letters. Polycarp wants to remove exactly kk characters (k≤nk≤n) from the string ss. Polycarp uses the following algorithm kk times: if ther...

Baiyi_destroyer的博客 539

Codeforces Round #490 (Div. 3)--Mishka and Contest,Reversing Encryption,Alphabetic Removals

A. Mishka and Contesttime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputMishka started participating in a programming contest. There are nn problems i...

maozhengxiang的博客 547

codeforces-954B(模拟+贪心字符串复制)

题面: You are given a string s consisting of n lowercase Latin letters. You have to type this string using your keyboard. Initially, you have an empty string. Until you type the whole string, you may ...

小冰球 987

Educational Codeforces Round 53 (Rated for Div. 2) A. Diverse Substring

A. Diverse Substring   You are given a string ss, consisting of nn lowercase Latin letters. A substring of string ss is a continuous segment of letters from ss. For example, "defor" is a substring ...

s540239976的博客 757

补题向 | Segment Occurrences(字符串)

B. Segment Occurrences You are given two strings ss and tt, both consisting only of lowercase Latin letters. The substring s[l..r]s[l..r] is the string which is obtained by taking characters sl,sl+1...

bekote的博客 746
上一篇: Intersecting Lines POJ - 1269(计算几何判断直线位置关系+求直线交点)
下一篇: String painter HDU - 2476(区间DP)
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值