傻逼题目,内存超限怎么办嘛,题目又不难,没超限的部分应该有分吧。
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
int N=scanner.nextInt(),M=scanner.nextInt(),T=scanner.nextInt(),res=0;
int[][] data=new int[N][M+3];
for (int i = 0; i < M; i++) {
int time=scanner.nextInt(),shop=scanner.nextInt();
data[shop-1][++data[shop-1][0]]=time;
}
for (int i = 0; i < N ; i++) {
int temp=0,current=0;
Arrays.sort(data[i],1,data[i][0]+1);
for (int j = 1; j <= data[i][0] ; j++) {
if (data[i][j]-current>1)temp-=data[i][j]-current-1;
temp=temp<0?0:temp;
temp+=2;
current=data[i][j];
if (temp>5)data[i][data[i][0]+1]=current;
if (temp<=3)data[i][data[i][0]+2]=current;
}
temp-=T-current;
if (temp>5)res++;
else if (temp>=4&&data[i][data[i][0]+1]>data[i][data[i][0]+2])res++;
}
System.out.println(res);
}
}