Untitled

 avatar
unknown
plain_text
4 years ago
2.6 kB
6
Indexable
Cho trước một danh sách rỗng. Người ta xét hai thao tác trên danh sách đó:
Thao tác "+V" (ở đây V là một số tự nhiên <= 1000000000): Nếu danh sách đang có ít hơn 15000 phần tử thì thao tác này bổ sung thêm phần tử V vào danh sách; nếu không, thao tác này không có hiệu lực.
Thao tác "-": Nếu danh sách đang không rỗng thì thao tác này loại bỏ tất cả các phần tử lớn nhất của danh sách; nếu không, thao tác này không có hiệu lực


Input
Dòng đầu tiên là số lượng test case T (T <= 50).
Dòng đầu của mỗi test case là số N (N <= 50.000) - số lượng thao tác. N dòng tiếp theo là thông tin về các thao tác.

Output
In ra đáp án cho mỗi test case trên 1 dòng.
đầu của mỗi test case là #C với C là thứ tự của test case.
thứ 2 là số lượng những giá trị còn lại trong danh sách.
thứ 3 liệt kê những giá trị đó theo thứ tự giảm dần.


Sample

Input

1
13
+1
+3
+2
+3
-
+4
+4
-
+2
+9
+7
+8
-

Output
#1 4 8 7 2 1





import java.util.Scanner;
import java.io.FileInputStream;

/*
As the name of the class should be Solution, using Solution.java as the filename is recommended.
In any case, you can execute your program by running 'java Solution' command.
*/
class Solution
{
	public static void main(String args[]) throws Exception
	{
		/*
		   The method below means that the program will read from input.txt, instead of standard(keyboard) input.
		   To test your program, you may save input data in input.txt file,
		   and call below method to read from the file when using nextInt() method.
		   You may remove the comment symbols(//) in the below statement and use it.
		   But before submission, you must remove the freopen function or rewrite comment symbols(//).
		 */
		//System.setIn(new FileInputStream("res/input.txt"));

		/*
		   Make new scanner from standard input System.in, and read data.
		 */
		Scanner sc = new Scanner(System.in);
		int T;
		T=sc.nextInt();
		/*
     			Read each test case from standard input.
     		*/

		for(int test_case = 1; test_case <= T; test_case++)
		{
		
			/////////////////////////////////////////////////////////////////////////////////////////////
			/*
				Please, implement your algorithm from this section.
			*/
			/////////////////////////////////////////////////////////////////////////////////////////////
	
		}
	}
}
Editor is loading...