-->
当前位置:首页 > 题库

PROGRAMMING:Depressed representative of Chinese class

Luz5年前 (2021-05-10)题库412
Sanqinghua ten university is a famous university with tens of thousands of students. As a representative of Chinese class, one of my tasks is to count the score of each student's test paper. This is a good job, but it's depressing that our teacher sun often gives students papers in order to let students practice. If she is in a good mood, she will give all the students the same number of papers. On the contrary, if you are in a bad mood, you may charge all students the same number of papers. Because she couldn't finish the papers, the students couldn't get them for a while.
It's disgusting for students to send and receive papers frequently, especially when collecting papers. Once a student finds that the number of papers in his hand is lower than that of a good student, he will leave sanqinghua ten university and join the post and Telecommunications Branch of Peking University. Every time a student leaves school, I have to delete his student status from the computer. Similarly, every time a new student joins the school, I have to create a new student status for him.
Miss sun often comes to me to ask about the students. She does not ask about the papers of a particular student, but how many papers are there in the hands of the students with the largest number of papers. At this time, I had to sort tens of thousands of students for a long time, and then tell her the answer.
Well, now you know a lot about my work. As you guessed, I'd like you to compile a statistical program. Well, isn't it very difficult? If a student's initial number of papers is less than that of a good student, it will not be included in the final answer
###Input format:
The first line has two non negative integers n and min. N is the number of commands below, and min is the number of papers a good student should have.
The next N lines, each representing a command. The command can be one of the following four types:
Name format function
I command I_ K create a new student status, the initial number of papers is K. If a student's initial number of papers is less than that of a good student, he will leave school immediately.
A command a_ K give each student a number of K papers
S command s_ The number of papers for each student is K
F command f_ K query the number of the kth most test paper
_( K in I, a and s commands is a non negative integer, and K in F command is a positive integer.
In the beginning, it can be considered that there are no students in the school.
###Output format:
The number of lines in the output file is the number of F commands plus one.
For each f command, your program should output a line, only containing an integer, which is the number of papers owned by the k-th student in the current number of papers. If K is greater than the current number of students, output - 1.
The last line of the output file contains an integer for the total number of students who left school.
###Input example:
Here is a set of inputs. For example:
```in
9 10
I 60
I 70
S 50
F 2
I 30
S 15
A 5
F 1
F 2
```
###Output example:
The corresponding output is given here. For example:
```out
ten
twenty
-1
two
```
###Note:
The number of I commands does not exceed 100000
The total number of a and s commands should not exceed 100
The number of F commands does not exceed 100000
The number of papers sent and received each time shall not exceed 1000
The number of test papers for new students should not exceed 100000







answer:If there is no answer, please comment