Java 代码
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] num = new int[n];//存放各队列的元素数量
while (scanner.hasNext()){
String string = scanner.nextLine();
String[] strings = string.split(” “);
if (strings[0].equals(“add”)){
num[0];
} else if (strings[0].equals(“sync”)) {
int a = Integer.parseInt(strings[1]);
if(num[a] < num[0]) num[a];
} else if (strings[0].equals(“query”)) {
int min = num[0];
for(int i = 1; i < n; i++)
min = Math.min(min,num[i]);
System.out.println(min);
}
}
}
}