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