fork download
  1. #pragma GCC optimize("Ofast")
  2. #pragma GCC optimize("unroll-loops")
  3. #pragma GCC optimize("inline")
  4. #include<bits/stdc++.h>
  5. using namespace std;
  6. template<class T> struct cLtraits_identity{
  7. using type = T;
  8. }
  9. ;
  10. template<class T> using cLtraits_try_make_signed =
  11. typename conditional<
  12. is_integral<T>::value,
  13. make_signed<T>,
  14. cLtraits_identity<T>
  15. >::type;
  16. void*wmem;
  17. char memarr[96000000];
  18. template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  19. static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  20. (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  21. (*arr)=(T*)(*mem);
  22. (*mem)=((*arr)+x);
  23. }
  24. template<class T> inline void walloc1d(T **arr, int x1, int x2, void **mem = &wmem){
  25. walloc1d(arr, x2-x1, mem);
  26. (*arr) -= x1;
  27. }
  28. template<class T1> void sortA_L(int N, T1 a[], void *mem = wmem){
  29. sort(a, a+N);
  30. }
  31. template<class T1> void rsortA_L(int N, T1 a[], void *mem = wmem){
  32. sortA_L(N, a, mem);
  33. reverse(a, a+N);
  34. }
  35. inline int my_getchar(){
  36. return getchar();
  37. }
  38. inline void rd(int &x){
  39. int k;
  40. int m=0;
  41. x=0;
  42. for(;;){
  43. k = my_getchar();
  44. if(k=='-'){
  45. m=1;
  46. break;
  47. }
  48. if('0'<=k&&k<='9'){
  49. x=k-'0';
  50. break;
  51. }
  52. }
  53. for(;;){
  54. k = my_getchar();
  55. if(k<'0'||k>'9'){
  56. break;
  57. }
  58. x=x*10+k-'0';
  59. }
  60. if(m){
  61. x=-x;
  62. }
  63. }
  64. inline int rd_int(void){
  65. int x;
  66. rd(x);
  67. return x;
  68. }
  69. inline void my_putchar(const int k){
  70. putchar(k);
  71. if(k=='\n'){
  72. fflush(stdout);
  73. }
  74. }
  75. template<class T> inline void wt_L(vector<T> x);
  76. template<class T> inline void wt_L(set<T> x);
  77. template<class T> inline void wt_L(multiset<T> x);
  78. template<class T1, class T2> inline void wt_L(pair<T1,T2> x);
  79. inline void wt_L(char a){
  80. my_putchar(a);
  81. }
  82. inline void wt_L(long long x){
  83. int s=0;
  84. int m=0;
  85. char f[20];
  86. if(x<0){
  87. m=1;
  88. x=-x;
  89. }
  90. while(x){
  91. f[s++]=x%10;
  92. x/=10;
  93. }
  94. if(!s){
  95. f[s++]=0;
  96. }
  97. if(m){
  98. my_putchar('-');
  99. }
  100. while(s--){
  101. my_putchar(f[s]+'0');
  102. }
  103. }
  104. int main(){
  105. int Nzj9Y0kE;
  106. wmem = memarr;
  107. int bkxOPzPX = rd_int();
  108. for(Nzj9Y0kE=(0);Nzj9Y0kE<(bkxOPzPX);Nzj9Y0kE++){
  109. int i;
  110. int N;
  111. rd(N);
  112. long long A[2*N];
  113. long long tmp = 1;
  114. int ress = 0;
  115. long long res[2*N];
  116. for(i=(0);i<(30);i++){
  117. A[i] = 1<<i;
  118. }
  119. for(i=(30);i<(N);i++){
  120. A[i] = 1000000000 - i;
  121. }
  122. {
  123. int OA9NF42T;
  124. if(N==0){
  125. wt_L('\n');
  126. }
  127. else{
  128. for(OA9NF42T=(0);OA9NF42T<(N-1);OA9NF42T++){
  129. wt_L(A[OA9NF42T]);
  130. wt_L(' ');
  131. }
  132. wt_L(A[OA9NF42T]);
  133. wt_L('\n');
  134. }
  135. }
  136. for(i=(0);i<(N);i++){
  137. A[N+i] = rd_int();
  138. }
  139. rsortA_L(2*N,A);
  140. int lmouyaID;
  141. cLtraits_try_make_signed<remove_reference<decltype((*((long long*)NULL)))>::type>::type Dc_3QP3Y;
  142. if(2*N==0){
  143. Dc_3QP3Y = 0;
  144. }
  145. else{
  146. Dc_3QP3Y = A[0];
  147. for(lmouyaID=(1);lmouyaID<(2*N);lmouyaID++){
  148. Dc_3QP3Y += A[lmouyaID];
  149. }
  150. }
  151. tmp =Dc_3QP3Y/ 2;
  152. for(i=(0);i<(2*N);i++){
  153. if(A[i] <= tmp){
  154. res[ress++] = A[i];
  155. tmp -= A[i];
  156. }
  157. }
  158. {
  159. int ClGtuHe4;
  160. if(ress==0){
  161. wt_L('\n');
  162. }
  163. else{
  164. for(ClGtuHe4=(0);ClGtuHe4<(ress-1);ClGtuHe4++){
  165. wt_L(res[ClGtuHe4]);
  166. wt_L(' ');
  167. }
  168. wt_L(res[ClGtuHe4]);
  169. wt_L('\n');
  170. }
  171. }
  172. }
  173. return 0;
  174. }
  175. template<class T> inline void wt_L(vector<T> x){
  176. int fg = 0;
  177. for(auto a : x){
  178. if(fg){
  179. my_putchar(' ');
  180. }
  181. fg = 1;
  182. wt_L(a);
  183. }
  184. }
  185. template<class T> inline void wt_L(set<T> x){
  186. int fg = 0;
  187. for(auto a : x){
  188. if(fg){
  189. my_putchar(' ');
  190. }
  191. fg = 1;
  192. wt_L(a);
  193. }
  194. }
  195. template<class T> inline void wt_L(multiset<T> x){
  196. int fg = 0;
  197. for(auto a : x){
  198. if(fg){
  199. my_putchar(' ');
  200. }
  201. fg = 1;
  202. wt_L(a);
  203. }
  204. }
  205. template<class T1, class T2> inline void wt_L(pair<T1,T2> x){
  206. wt_L(x.first);
  207. my_putchar(' ');
  208. wt_L(x.second);
  209. }
  210. // cLay version 20220312-1
  211.  
  212. // --- original code ---
  213. // //interactive
  214. // REP(rd_int()){
  215. // int @N;
  216. // ll A[2*N], tmp = 1;
  217. // int ress = 0; ll res[2*N];
  218. // rep(i,30) A[i] = 1<<i;
  219. // rep(i,30,N) A[i] = 1d9 - i;
  220. // wt(A(N));
  221. // rep(i,N) A[N+i] = rd_int();
  222. // rsortA(2*N,A);
  223. // tmp = sum(A(2*N)) / 2;
  224. // rep(i,2*N) if(A[i] <= tmp) res[ress++] = A[i], tmp -= A[i];
  225. // wt(res(ress));
  226. // }
  227.  
Time limit exceeded #stdin #stdout 5s 5516KB
stdin
Standard input is empty
stdout
Standard output is empty