package wangyi1; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int size = sc.nextInt(); int handle = 0; int lab = 0; int ishan[] = new int[size]; int cursize=0; for (int i = 0; i < n; i++) { String s = sc.next(); if (s.equals("new")) { int k = sc.nextInt(); if (cursize+k <= size) { handle++; cursize+=k; while (--k >= 0) { while(ishan[lab]!=0) lab++; ishan[lab++] = handle; } System.out.println(handle); } else System.out.println("NULL"); } if (s.equals("del")) { int k = sc.nextInt(); int cnt = 0; int first=0; for (int j = 0; j < size; j++) { if (ishan[j] == k) { if(first==0) lab=j; first=1; ishan[j] = 0; cnt++; } } if (cnt == 0) System.out.println("ILLEGAL_OPERATION"); cursize-=cnt; } if (s.equals("def")) { int blank = size - 1; for (int j = size - 1; j >= 0; j--) { for (int l = size - 1; l >= 1; l--) { if (ishan[l] == 0 && ishan[l - 1] != 0) { int tmp = ishan[l]; ishan[l] = ishan[l - 1]; ishan[l - 1] = tmp; } } } if (ishan[0] == 0) lab = 0; else lab = n - 1; } for (int j = 0; j < size; j++) System.out.print(ishan[j] + " "); System.out.println("size "+cursize); } } }
点赞 评论

相关推荐

Twilight_m...:还是不够贴近现实,中关村那块60平房子200万怎么可能拿的下来,交个首付还差不多
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务