样例和测试点都能过,甚至测试点的输入数据在本地输出和他描述的输出是不一样的.
比如他说的是Wrong Answer.wronganswer on line 1 column1, read 9, expected 1.就是第一个数字读到9,但我在本地的输出是一个整数13,想破脑袋也想不到怎么出来个9的.
以下是代码:
#include<iostream>
#include<algorithm>
using namespace std;
int a[255];
int t[255];
int main() {
char c;
int i, n, x, y=0;
long long out = 0;
for (i = 0; (c = getchar()) != '\n'; i++) {
a[i] = c - 48;
t[i] = a[i];
}
sort(t,t+i);
cin >> n;
x = t[i - n];
for (int j = i-1; j >=i-n; j--) {
if (t[j] == x)y++;
}
for (int j = 0; j < i; j++) {
if (a[j] < x) {
out *= 10;
out += a[j];
}
if (a[j] == x) {
if (y > 0)y--;
else {
out *= 10;
out += a[j];
}
}
}
cout <<out<< endl;
return 0;
}