Java蓝桥杯2019真题试题G:外卖优先级(超简洁,易懂,有注释,不懂顺便问)
试题G:外卖店优先级
Java题解
public class gTakeOut {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int t = sc.nextInt();
int[][] arr = new int[n][t];
for (int i = 0; i < m; i++) {
int ts = sc.nextInt();
int id = sc.nextInt();
arr[id - 1][ts - 1] += 1;
}
int count = 0;
for (int i = 0; i < n; i++) {
int level = 0;
for (int j = 0; j < t; j++) {
if (arr[i][j] == 0) {
if (level == 0) continue;
level--;
} else {
level += arr[i][j] * 2;
}
}
if (level > 5) count++;
}
System.out.println(count);
}
}