@@ -0,0 +1,15 @@
+#include<bits/stdc++.h>
+
+using namespace std;
+int main() {
+ for (string s; cin >> s;) {
+ char max_char = *max_element(s.begin(), s.end());
+ for (char c:s) {
+ cout << c;
+ if (c == max_char)cout << "(max)";
+ }
+ cout << endl;
+ return 0;
+}
@@ -0,0 +1,23 @@
+//O(n*log(m))
+ int m, n;
+ cin >> m >> n;
+ vector<int> a(m, 0), b(n, 0);
+ for (auto &i:a)cin >> i;
+ for (auto &i:b)cin >> i;
+ sort(a.begin(), a.end());
+ sort(b.begin(), b.end());
+ if (m < n)swap(a, b);
+ auto best = INT_MAX;
+ for (auto x:a) {
+ auto p = lower_bound(b.begin(), b.end(), x);
+ best = min(best, abs(*p - x));
+ if (best == 0)break;
+ cout << best << endl;
@@ -0,0 +1,46 @@
+int a[21];
+int used[21];
+int n;
+int tot = 0;
+bool flag = false;
+void dfs(int k) {
+ if (flag)return;
+ if (k == n) {
+ int sum = 0;
+ for (int i = 0; i < k; i++) {
+ if (used[i])sum += a[i];
+ if (sum == tot)flag = true;
+ return;
+ used[k] = false;
+ dfs(k + 1);
+ used[k] = true;
+ while (cin >> n) {
+ fill(used, used + n, false);
+ flag = false;
+ tot = 0;
+ for (int i = 0; i < n; i++) {
+ cin >> a[i];
+ tot += a[i];
+ if (tot % 2 == 0) {
+ tot /= 2;
+ dfs(0);
+ if (flag)
+ cout << "Of course,I can!" << endl;
+ else
+ cout << "Sorry,I can't!" << endl;
@@ -0,0 +1,18 @@
+int main() {//n!
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7};
+ do {
+ bool ok = true;
+ for (int i = 0; i < 8; i++)
+ for (int j = i + 1; j < 8; j++)
+ if (abs(a[i] - a[j]) == j - i)
+ ok = false;
+ if (ok)
+ cout << a[0] << a[1] << a[2] << a[3] << a[4] << a[5] << a[6] << a[7] << endl;
+ } while (next_permutation(a, a + 8));
@@ -0,0 +1,27 @@
+#include <bits/stdc++.h>
+ vector<int> F(1, 1);
+ for (int i = 2; i <= 9; i++) {
+ F.push_back(F[F.size() - 1] * i);
+ int T;
+ cin >> T;
+ while (T--) {
+ int n;
+ cin >> n;
+ for (int i = F.size() - 1; i >= 0; i--) {
+ if (F[i] <= n) {
+ n -= F[i];
+ if (n == 0) {
+ cout << "Yes" << endl;
+ } else {
+ cout << "No" << endl;