SHARE
TWEET

Untitled

a guest Jul 12th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program zadd;
  2.  
  3. var
  4.   typeOfOil, a, prev, last : array [1..100000] of Integer ;
  5.   i, n, k, p, cnt :Integer;
  6.   sign : char;
  7.  
  8. procedure  push(k, x:Integer;);
  9. begin
  10.   inc(cnt);
  11.   if (last[k] > p) then begin
  12.     WriteLn('ERROR');
  13.     exit;
  14.   end ;
  15.   a[cnt] := x;
  16.   prev[cnt] := last[k];
  17.   last[k] := cnt;
  18. end;
  19.  
  20. procedure pop(k:Integer);
  21. begin
  22.   if (typeOfOil[last[k]] = typeOfOil[I]) then
  23.     last[k] := prev[last[k]]
  24.   else begin
  25.     writeln('ERROR');
  26.     exit;
  27.   end;
  28. end;
  29.  
  30. {procedure top(k:Integer) ;
  31. begin
  32.   top := a[last[k]];
  33. end;}
  34.  
  35. begin
  36.   cnt := 0;
  37.   read(n, k, p);
  38.   for i := 1 to n do begin
  39.     read(sign, k, typeOfOil[i]);
  40.     if (sign = '+') then
  41.       push(k, typeOfOil[i])
  42.     else
  43.       pop(k);
  44.   end;
  45.   WriteLn(p);
  46.   //exit;
  47.   //writeln(k,' ',last[k],' ' ,a[last[k]]);
  48. end.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top