Guest User

ZCO VIDEO GAME

a guest
Oct 1st, 2017
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. import java.io.BufferedReader;
  2.  
  3. import java.io.IOException;
  4.  
  5. import java.io.InputStreamReader;
  6.  
  7. import java.util.*;
  8.  
  9. import java.util.StringTokenizer;
  10.  
  11. public class Main
  12.  
  13. {
  14.  
  15. static class FastReader
  16.  
  17. {
  18.  
  19. BufferedReader br;
  20.  
  21. StringTokenizer st;
  22.  
  23. public FastReader()
  24.  
  25. {
  26.  
  27. br = new BufferedReader(new
  28.  
  29. InputStreamReader(System.in));
  30.  
  31. }
  32.  
  33. String next()
  34.  
  35. {
  36.  
  37. while (st == null || !st.hasMoreElements())
  38.  
  39. {
  40.  
  41. try
  42.  
  43. {
  44.  
  45. st = new StringTokenizer(br.readLine());
  46.  
  47. }
  48.  
  49. catch (IOException e)
  50.  
  51. {
  52.  
  53. e.printStackTrace();
  54.  
  55. }
  56.  
  57. }
  58.  
  59. return st.nextToken();
  60.  
  61. }
  62.  
  63. int nextInt()
  64.  
  65. {
  66.  
  67. return Integer.parseInt(next());
  68.  
  69. }
  70.  
  71. long nextLong()
  72.  
  73. {
  74.  
  75. return Long.parseLong(next());
  76.  
  77. }
  78.  
  79. double nextDouble()
  80.  
  81. {
  82.  
  83. return Double.parseDouble(next());
  84.  
  85. }
  86.  
  87. String nextLine()
  88.  
  89. {
  90.  
  91. String str = "";
  92.  
  93. try
  94.  
  95. {
  96.  
  97. str = br.readLine();
  98.  
  99. }
  100.  
  101. catch (IOException e)
  102.  
  103. {
  104.  
  105. e.printStackTrace();
  106.  
  107. }
  108.  
  109. return str;
  110.  
  111. }
  112.  
  113. }
  114.  
  115. public static void main(String[] args)
  116.  
  117. {
  118.  
  119. FastReader in=new FastReader();
  120.  
  121. int N = in.nextInt();
  122.  
  123. int H = in.nextInt();
  124.  
  125. long[] boxes = new long[N];
  126.  
  127. for(int i = 0; i< N;i++)boxes[i] = in.nextLong();
  128.  
  129. int c = 0, pos = 0;
  130.  
  131. boolean hold = false;
  132.  
  133. while((c = in.nextInt()) != 0){
  134.  
  135. if(c == 1)pos = Math.max(0, pos-1);
  136.  
  137. if(c == 2)pos = Math.min(N-1, pos+1);
  138.  
  139. if(c == 3){
  140.  
  141. if(boxes[pos] >0 && !hold){
  142.  
  143. boxes[pos]--;
  144.  
  145. hold = true;
  146.  
  147. }
  148.  
  149. }
  150.  
  151. if(c == 4){
  152.  
  153. if(boxes[pos] < H && hold){
  154.  
  155. boxes[pos]++;
  156.  
  157. hold = false;
  158.  
  159. }
  160.  
  161. }
  162.  
  163. }
  164.  
  165. for(int i = 0; i< N; i++)System.out.print(boxes[i] + " ");
  166.  
  167. }
  168.  
  169. }
Add Comment
Please, Sign In to add comment