视频中的标准程序代码如下:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int N = 15;
int[] pos = new int[N];
int n = scanner.nextInt();
scanner.nextLine(); // consume the newline character after n
while (scanner.hasNext()) {
String x = scanner.next();
if (x.equals("add")) {
int y = scanner.nextInt();
pos[0]++;
} else if (x.equals("sync")) {
int y = scanner.nextInt();
pos[y]++;
pos[y] = Math.min(pos[y], pos[0]);
} else if (x.equals("query")) {
int ans = Integer.MAX_VALUE;
for (int j = 0; j < n; j++) ans = Math.min(ans, pos[j]);
System.out.println(ans);
}
}
scanner.close();
}
}
3 回复
0 转发
1 喜欢
9 阅读



