Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
227904 232214陈皓轩 基础算法-贪心算法:删除问题 C++ 解答错误 40 0 MS 272 KB 490 2023-12-31 15:51:45

Tests(2/5):


#include <iostream> using namespace std; string n; int s; bool comp(string a, string b) { if (a.size() > b.size()) return 1; if (a.size() < b.size()) return 0; for (int i = 0; i < a.size(); i++) { if (a[i] < b[i]) return 0; } return 1; } int main() { cin >> n >> s; while (s--) { string ans(n); for (int i = 0; i < n.size(); i++) { if (comp(ans, n.substr(0, i) + n.substr(i + 1))) ans = n.substr(0, i) + n.substr(i + 1); } n = ans; } cout << n; }


测评信息: