只要读懂题意应该就没问题了吧。。找字符串的字典序最大子序,从后往前找比较方便,最后逆序输出
/***********************************************
* Author: fisty
* Created Time: 2015/2/4 21:15:20
* File Name : 3_D.cpp
*********************************************** */
#include <iostream>
#include <cstring>
#include <deque>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <cstdio>
#include <bitset>
#include <algorithm>
using namespace std;
#define Debug(x) cout << #x << " " << x <<endl
#define Memset(x, a) memset(x, a, sizeof(x))
const int INF = 0x3f3f3f3f;
typedef long long LL;
typedef pair<int, int> P;
#define FOR(i, a, b) for(int i = a;i < b; i++)
#define MAX_N 1000100
int main() {
//freopen("in.txt", "r", stdin);
//cin.tie(0);
//ios::sync_with_stdio(false);
char s[MAX_N];
char ans[MAX_N];
while(scanf("%s",s) != EOF){
char max = 0;
int len = 0;
for(int i = strlen(s)-1;i >= 0; i--){
if(s[i] >= max){
max = s[i];
ans[len++] = s[i];
}
}
for(int i = strlen(ans)-1; i >= 0; i--){
cout << ans[i];
}
cout << endl;
}
return 0;
}