[UVA-11039]Children's Game

解析

微扰法贪心经典题

代码

#include <bits/stdc++.h>
using namespace std;

bool cmp(const string &x, const string &y) {
	return x + y > y + x;
}

int main() {
	int n;
	while (~scanf("%d", &n) && n) {
		string str[55];
		for (int i = 1; i <= n; ++ i) cin >> str[i];
		sort(str + 1, str + n + 1, cmp);
		for (int i = 1; i <= n; ++ i) cout << str[i];
		putchar(10);
	}
}
posted @ 2018-11-24 10:16  AlessandroChen  阅读(103)  评论(0编辑  收藏  举报