Educational Codeforces Round 54---A.........【未完成】
阿新 • • 發佈:2018-11-13
sin hid str != lag stream char names i++
A---Minimizing the String
1 #include<iostream> 2 #include<cstdio> 3 #include<cmath> 4 #include<cstdlib> 5 #include<cstring> 6 #include<algorithm> 7 #include<queue> 8 using namespace std; 9 #define ll long long 10 #define N 100010 11 #define pi 3.1415926535 12View Code13 int n; 14 const int maxn = 2e5 + 5; 15 char str[maxn], ans[maxn]; 16 17 int main() 18 { 19 while(scanf("%d", &n) != EOF){ 20 memset(ans, 0, sizeof(ans)); 21 memset(str, 0, sizeof(str)); 22 scanf("%s", str); 23 int len = 0; 24 bool flag = true; 25 for(int i = 0; i < n - 1; i++){ 26 if(str[i] > str[i + 1] && flag){ 27 flag = false; 28 continue; 29 } 30 ans[len++] = str[i]; 31 } 32 if(!flag){ 33 ans[len++] = str[n - 1]; 34 } 35 36 37printf("%s\n", ans); 38 } 39 return 0; 40 }
Educational Codeforces Round 54---A.........【未完成】