import java.util.*; public class first { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int T = scan.nextInt(); int MaxMem = scan.nextInt(); while (scan.hasNextLine() && T >= 1 && T <= 10000 && MaxMem >= 1 && MaxMem <= 10000){ scan.nextLine(); //换行符 int nowSize = 0; List<Integer> handle = new ArrayList<Integer>(); int remove = 0;int count = 0; int removeIndex = -1; for(int i = 0; i < T; i++){ String[] operate = scan.nextLine().split(" "); if(operate[0].equals("new")){ int num = Integer.parseInt(operate[1]); nowSize += num; if(nowSize <= MaxMem){ System.out.println(++count); handle.add(num); } else { nowSize -= num; System.out.println("NULL");} } if(operate[0].equals("del")){ int handlenum = Integer.parseInt(operate[1]); if(handlenum < handle.size()+1){ remove += handle.get(handlenum-1); removeIndex = handlenum-1; } else System.out.println("ILLEGAL_OPERATION"); } if(operate[0].equals("def")){ handle.remove(removeIndex); nowSize -= remove; } } } } }
内存管理--360笔试
最新推荐文章于 2023-01-15 21:29:05 发布