시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB47912206173350.246%

문제

어떤 수열을 읽고, 홀수번째 수를 읽을 때 마다, 지금까지 입력받은 값의 중앙값을 출력하는 프로그램을 작성하시오.

예를 들어, 수열이 1, 5, 4, 3, 2 이면, 홀수번째 수는 1번째 수, 3번째 수, 5번째 수이고, 1번째 수를 읽었을 때 중앙값은 1, 3번째 수를 읽었을 때는 4, 5번째 수를 읽었을 때는 3이다.

입력

첫째 줄에 테스트 케이스의 개수 T(1 ≤ T ≤ 1,000)가 주어진다. 각 테스트 케이스의 첫째 줄에는 수열의 크기 M(1 ≤ M ≤ 9999, M은 홀수)이 주어지고, 그 다음 줄부터 이 수열의 원소가 차례대로 주어진다. 원소는 한 줄에 10개씩 나누어져있고, 32비트 부호있는 정수이다.

출력

각 테스트 케이스에 대해 첫째 줄에 출력하는 중앙값의 개수를 출력하고, 둘째 줄에는 홀수 번째 수를 읽을 때 마다 구한 중앙값을 차례대로 공백으로 구분하여 출력한다. 이때, 한 줄에 10개씩 출력해야 한다.

예제 입력 1

3
9
1 2 3 4 5 6 7 8 9
9
9 8 7 6 5 4 3 2 1
23
23 41 13 22 -3 24 -31 -11 -8 -7
3 5 103 211 -311 -45 -67 -73 -81 -99
-33 24 56

예제 출력 1

5
1 2 3 4 5
5
9 8 7 6 5
12
23 23 22 22 13 3 5 5 3 -3
-7 -3
W3sicHJvYmxlbV9pZCI6IjI2OTYiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWM5MTFcdWM1NTlcdWFjMTIgXHVhZDZjXHVkNTU4XHVhZTMwIiwiZGVzY3JpcHRpb24iOiI8cD5cdWM1YjRcdWI1YTQgXHVjMjE4XHVjNWY0XHVjNzQ0IFx1Yzc3ZFx1YWNlMCwgXHVkNjQwXHVjMjE4XHViYzg4XHVjOWY4IFx1YzIxOFx1Yjk3YyBcdWM3N2RcdWM3NDQgXHViNTRjIFx1YjljOFx1YjJlNCwgXHVjOWMwXHVh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HNldCBjb250YWlucyBhbiBvZGQgZGVjaW1hbCBpbnRlZ2VyIE0sICgxICZsZTsgTSAmbGU7IDk5OTkpLCBnaXZpbmcgdGhlIHRvdGFsIG51bWJlciBvZiBzaWduZWQgaW50ZWdlcnMgdG8gYmUgcHJvY2Vzc2VkLiBUaGUgcmVtYWluaW5nIGxpbmUocykgaW4gdGhlIGRhdGFzZXQgY29uc2lzdHMgb2YgdGhlIHZhbHVlcywgMTAgcGVyIGxpbmUsIHNlcGFyYXRlZCBieSBhIHNpbmdsZSBzcGFjZS4gVGhlIGxhc3QgbGluZSBpbiB0aGUgZGF0YXNldCBtYXkgY29udGFpbiBsZXNzIHRoYW4gMTAgdmFsdWVzLiZuYnNwOzxcL3A+XHJcbiIsIm91dHB1dCI6IjxwPkZvciBlYWNoIGRhdGEgc2V0IHRoZSBmaXJzdCBsaW5lIG9mIG91dHB1dCBjb250YWlucyB0aGUgbnVtYmVyIG9mIG1lZGlhbnMgb3V0cHV0ICh3aGljaCBzaG91bGQgYmUgb25lLWhhbGYgdGhlIG51bWJlciBvZiBpbnB1dCB2YWx1ZXMgcGx1cyBvbmUpLiBUaGUgb3V0cHV0IG1lZGlhbnMgd2lsbCBiZSBvbiB0aGUgZm9sbG93aW5nIGxpbmVzLCAxMCBwZXIgbGluZSBzZXBhcmF0ZWQgYnkgYSBzaW5nbGUgc3BhY2UuIFRoZSBsYXN0IGxpbmUgbWF5IGhhdmUgbGVzcyB0aGFuIDEwIGVsZW1lbnRzLCBidXQgYXQgbGVhc3QgMSBlbGVtZW50LiBUaGVyZSBzaG91bGQgYmUgbm8gYmxhbmsgbGluZXMgaW4gdGhlIG91dHB1dC48XC9wPlxyXG4iLCJoaW50IjoiIiwib3JpZ2luYWwiOiIxIiwiaHRtbF90aXRsZSI6IjAiLCJwcm9ibGVtX2xhbmdfdGNvZGUiOiJFbmdsaXNoIn1d

출처

ICPC > Regionals > North America > Greater New York Region > 2009 Greater New York Programming Contest D번

  • 문제를 번역한 사람: baekjoon
  • 데이터를 추가한 사람: keunbum
  • 잘못된 데이터를 찾은 사람: tncks0121