Run ID | Author | Problem | Lang | Verdict | Score | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|---|
227801 | 232214陈皓轩 | 基础算法-贪心算法:删除问题 | C++ | Wrong Answer | 20 | 0 MS | 272 KB | 559 | 2023-12-31 13:53:16 |
#include <iostream> #include <vector> #include <map> #include <algorithm> using namespace std; string n; int s; map<int, bool> nhav; struct Node { int id, v; bool operator<(const Node &rhs) const { if (v == rhs.v) return id < rhs.id; return v > rhs.v; } }; vector<Node> vec; int main() { cin >> n >> s; for (int i = 0; i < n.size(); i++) { vec.push_back({i, n[i]}); } sort(vec.begin(), vec.end()); for (int i = 0; i < s; i++) { nhav[vec[i].id] = 1; } for (int i = 0; i < n.size(); i++) if (!nhav[i]) cout << n[i]; }