Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
83007 sh25_shenpy 联接最大数 C++ 通过 0 MS 248 KB 819 2026-01-18 21:00:55

Tests(4/4):


#include <iostream> #include <vector> #include <string> #include <algorithm> using namespace std; // 自定义排序规则:比较a+b和b+a的大小,降序排列 bool compare(const string& a, const string& b) { return a + b > b + a; } int main() { int n; // 读取数字个数 cin >> n; vector<string> nums; // 读取n个数字,转为字符串存储 for (int i = 0; i < n; ++i) { string num; cin >> num; nums.push_back(num); } // 按照自定义规则排序 sort(nums.begin(), nums.end(), compare); // 拼接所有字符串得到结果 string result; for (const string& s : nums) { result += s; } // 输出结果 cout << result << endl; return 0; }


测评信息: