E. A Magic Lamp

Time Limit: 1000ms
Case Time Limit: 1000ms
Memory Limit: 32768KB
 
64-bit integer IO format: %I64d      Java class name: Main
 
 
Kiki likes traveling. One day she finds a magic lamp, unfortunately the genie in the lamp is not so kind. Kiki must answer a question, and then the genie will realize one of her dreams. 
The question is: give you an integer, you are allowed to delete exactly m digits. The left digits will form a new integer. You should make it minimum.
You are not allowed to change the order of the digits. Now can you help Kiki to realize her dream?

 

Input

There are several test cases.
Each test case will contain an integer you are given (which may at most contains 1000 digits.) and the integer m (if the integer contains n digits, m will not bigger then n). The given integer will not contain leading zero.

 

Output

For each case, output the minimum result you can get in one line.
If the result contains leading zero, ignore it.

 

Sample Input

178543 4
1000001 1
100001 2
12345 2
54321 2
 

Sample Output

13
1
0
123
321
 
 解题:本来要RMQ做的,不明白啊!
 
 #include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#define LL long long
using namespace std;
char str[];
int main(){
int m,len,i,top;
while(scanf("%s %d",str,&m) == ){
len = strlen(str);
top = ;
for(i = ; i < len;){
if(m && top >= && str[top] > str[i]){m--;top--;}
else if(top != - || str[i] != '') str[++top] = str[i++];
else i++;
}
while(top >= && m){top--;m--;}
if(top == -) str[++top] = '';
str[++top] = '\0';
printf("%s\n",str);
}
return ;
}

E. A Magic Lamp的更多相关文章

  1. HDOJ 3183 A Magic Lamp

    A Magic Lamp Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  2. hdu 3183 A Magic Lamp(RMQ)

    题目链接:hdu 3183 A Magic Lamp 题目大意:给定一个字符串,然后最多删除K个.使得剩下的组成的数值最小. 解题思路:问题等价与取N-M个数.每次取的时候保证后面能取的个数足够,而且 ...

  3. A Magic Lamp(贪心+链表)

    A Magic Lamp Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

  4. hdu 3183 A Magic Lamp RMQ ST 坐标最小值

    hdu 3183 A Magic Lamp RMQ ST 坐标最小值 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3183 题目大意: 从给定的串中挑 ...

  5. HDU 3183 - A Magic Lamp - [RMQ][ST算法]

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3183 Problem DescriptionKiki likes traveling. One day ...

  6. A Magic Lamp -- hdu -- 3183

    http://acm.hdu.edu.cn/showproblem.php?pid=3183 A Magic Lamp Time Limit: 2000/1000 MS (Java/Others)   ...

  7. hdu 3183 A Magic Lamp(RMQ)

    A Magic Lamp                                                                               Time Limi ...

  8. hdu 3183 A Magic Lamp rmq或者暴力

    A Magic Lamp Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Pro ...

  9. hdu A Magic Lamp

    http://acm.hdu.edu.cn/showproblem.php?pid=3183 A Magic Lamp Time Limit: 2000/1000 MS (Java/Others)   ...

  10. HDU_3183_A Magic Lamp

    A Magic Lamp Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Tota ...

随机推荐

  1. arcgis mdb 数据中的shp 如何合并一起

    如上操作  一直往下就可以啦 选择数据源 就可以了,然后就可以load  其他数据啦   ,坐标系要一直

  2. Android中的ListView属性使用总结

    Android中使用ListView控件比较常见,如果能知道常用的一些属性使用,肯定会少很多坑. 1.ListView是常用的显示控件,默认背景是和系统窗口一样的透明色,如果给ListView加上背景 ...

  3. c语言中的->代表什么意思

    c语言中 ->符号是什么意思? 比如c=a->b a为结构体或联合体的指针,->表示调用其成员

  4. IOS之网络状态设和NSUserDefaults的synchronize

    #pragma mark - check net status int apiCheckNetStatus() { Reachability *reachNet = [Reachability rea ...

  5. php关于精准计算的模块 BCMath

    Php: BCMath bc是Binary Calculator的缩写.bc*函数的参数都是操作数加上一个可选的 [int scale],比如string bcadd(string $left_ope ...

  6. LR中订单流程脚本

    Action(){ /* 主流程:登录->下订单->支付订单->获取订单列表 定义事物 1)登录 2)下订单 3)支付订单 4)获取订单列表 接口为:application/json ...

  7. APP弱网测试点

  8. sql 函数 coalesce

    SQL函数 coalesce 功能: 返回参数中第一个非null的值. 语法: coalesce(参数1,参数2,参数3,...);返回第一个非null的值. 一般情况下会与Nullif()函数一起使 ...

  9. vijos 1448 校门外的树 (不是05年普及组那题)

    描述 校门外有很多树,有苹果树,香蕉树,有会扔石头的,有可以吃掉补充体力的……如今学校决定在某个时刻在某一段种上一种树,保证任一时刻不会出现两段相同种类的树,现有两个操作:K=1,K=1,读入l.r表 ...

  10. maven打包错误:java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=...) with your test

    Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.118 sec <<< FAILURE! - in ...