#include<stdio.h> #include<string> #include<iostream> #include<algorithm> #include<string.h> #include<vector> #include<queue> #include<set> #include<map> // #define int long long intread(int x = 0, int f = 0, char ch = getchar()) { while (ch < 48or57 < ch) f = ch == 45, ch = getchar(); while(48 <= ch and ch <= 57) x = x * 10 + ch - 48, ch = getchar(); return f ? -x : x; } constint N = 3e5 + 5; int n; structNode { int x, y; boolfriendoperator < (Node a, Node b) { return a.x + a.y < b.x + b.y; } } a[N];
voidsolve() { n = read(); for (int i = 1; i <= n; i++) a[i].x = read(); for (int i = 1; i <= n; i++) a[i].y = read(); std::sort(a + 1, a + 1 + n); for (int i = 1; i <= n; i++) printf("%d ", a[i].x); puts(""); for (int i = 1; i <= n; i++) printf("%d ", a[i].y); puts(""); }
signedmain() { #ifndef ONLINE_JUDGE freopen("B.in", "r", stdin); #endif for (int T = read(); T--; solve()); return0; }
#include<stdio.h> #include<string> #include<iostream> #include<algorithm> #include<string.h> #include<vector> #include<queue> #include<set> #include<map> #define int long long intread(int x = 0, int f = 0, char ch = getchar()) { while (ch < 48or57 < ch) f = ch == 45, ch = getchar(); while(48 <= ch and ch <= 57) x = x * 10 + ch - 48, ch = getchar(); return f ? -x : x; }
voidsolve() { int a = read(), b = read(), r = read(); int k = 0, ans = 0; if (a < b) std::swap(a, b); for (int i = 63; i >= 0; i--) if (((a >> i) & 1LL) == 1and ((b >> i) & 1LL) == 0) { k = i; break; } // printf("k : %lld\n", k); for (int i = k - 1; i >= 0; i--) { int x = (a >> i) & 1LL, y = (b >> i) & 1LL; if (x == 1and y == 0) { if (ans + (1LL << i) <= r) ans += 1LL << i; } } // printf("[%lld]\n", ans); int x = a ^ ans; int y = b ^ ans; printf("%lld\n", x - y); }
signedmain() { #ifndef ONLINE_JUDGE freopen("C.in", "r", stdin); #endif for (int T = read(); T--; solve()); return0; }
#include<stdio.h> #include<string> #include<iostream> #include<algorithm> #include<string.h> #include<vector> #include<queue> #include<set> #include<map> #define int long long intread(int x = 0, int f = 0, char ch = getchar()) { while (ch < 48or57 < ch) f = ch == 45, ch = getchar(); while(48 <= ch and ch <= 57) x = x * 10 + ch - 48, ch = getchar(); return f ? -x : x; } constint N = 1e6 + 5; constint INF = 1LL << 60; int n, a[N], sum[N], q[N], f[N]; booljudge(int lim) { int h = 1, t = 0; q[++t] = 0; for (int i = 0; i <= n + 1; i++) f[i] = 0; for (int i = 1; i <= n + 1; i++) { for (; h <= t and sum[i - 1] - sum[q[h]] > lim; h++); f[i] = a[i] + f[q[h]]; for (; h <= t and f[i] <= f[q[t]]; t--); q[++t] = i; } return f[n + 1] <= lim; } voidsolve() { n = read(); for (int i = 1; i <= n; i++) a[i] = read(); a[n + 1] = 0; for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i]; int ans = 0; for (int L = 1, R = sum[n], mid; L <= R; ) if (judge(mid = (L + R) >> 1)) ans = mid, R = mid - 1; else L = mid + 1; std::cout << ans << '\n'; }
signedmain() { #ifndef ONLINE_JUDGE freopen("D.in", "r", stdin); #endif for (int T = read(); T--; solve()); return0; }