Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
227907 232214陈皓轩 基础算法-贪心算法:删除问题 C++ 通过 100 0 MS 272 KB 545 2023-12-31 15:55:26

Tests(5/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; } while (n[0] == '0' && n.size() > 1) n = n.substr(1); cout << n; }


测评信息: