SGU 296

题意:给你一个最多1000位的数,让你删除k位使得剩下的数最大

收获:贪心

#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl;
#define dd(x) cout<<#x<<"="<<x<<" ";
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define ll long long
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define pdd pair<double,double>
#define pdi pair<double,int>
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define ull unsigned long long
#define ll long long
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define db double
#define all(a) a.begin(),a.end()
const int mod = 1e9+;
const int maxn = 1e3+;
const double eps = 1e-;
using namespace std;
bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=;a%=mod; if(b<) return ; for(;b;b>>=){if(b&)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
ll x=,f=;char ch=getchar();
while (ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while (ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
string s;
int main(){
qc;
int k;
cin>>s>>k;
rep(i,,sz(s)){
while(k&&s[i]>s[i-]){
s.erase(s.begin()+i-);
i--;k--;
if(!i) break;
}
}
while(k--) s.erase(s.end()-);
cout<<s<<endl;
return ;
}

最新文章

  1. Oracle下批量将一个用户的所有表的select权限赋值给另外一个用户
  2. POJ 3061 (二分+前缀和or尺取法)
  3. dom4j解析xml文档(增删改查)
  4. 以对象的方式来访问xml数据表(一)
  5. 【转】Dr.com 5.20破解教程
  6. 最小生成树 10.1.5.253 1505 poj 1258 http://poj.org/problem?id=1258
  7. SWTBOK測试实践系列(4) -- 软件測试技术的黑白之道
  8. Hibernate 多对多映射
  9. Docker其它安全特性
  10. Linux重要命令总结
  11. 使用VMWare虚拟机打开MFC报错:不支持16位系统
  12. LeetCode(35):搜索插入位置
  13. 《大型分布式网站架构》学习笔记--01SOA
  14. Mac通过安装Go2Shell实现“在当前目录打开iTerm2”
  15. 解决GitHub下载速度比较慢
  16. 100. Same Tree (Tree;DFS)
  17. 2018.12.19 codeforces 1092F. Tree with Maximum Cost(换根dp)
  18. centos下完全卸载mysql(别人写的,我仅仅为了学习记录)
  19. python进程间通信 实例
  20. JS中Date.parse()和Date.UTC()返回值不一致

热门文章

  1. spring中操作mysql数据库
  2. HDU 4585 Shaolin(STL map)
  3. 3.IntelliJ IDEA 使用详解
  4. luogu 3393 逃离僵尸岛
  5. Java类和对象11
  6. Python中的self(Python笔记)
  7. &lt;Sicily&gt;Fibonacci 2
  8. ivew语法中&#39;${}`的用法
  9. 用树链剖分来写LCA
  10. windows下用winscp的root连接ubuntu“拒绝访问”的解决方法