fork download
  1. program diaper;
  2.  
  3. const
  4. MAXN = 100;
  5.  
  6. var
  7. K, N, i, milk, food : LongInt;
  8. F : array[0..MAXN-1] of longint;
  9. B : array[0..MAXN-1] of char; (*per il carattere blank tra il numero e il tipo di pasto*)
  10. T : array[0..MAXN-1] of char;
  11. begin
  12.  
  13. (*assign(input, 'input.txt'); reset(input);
  14.   assign(output, 'output.txt'); rewrite(output);*)
  15.  
  16.  
  17. ReadLn(N);
  18.  
  19. for i:=0 to N-1 do readln (F[i],B[i],T[i]);
  20.  
  21. K := 0; milk:=0; food:=0;
  22.  
  23. for i:=0 to N-1 do
  24. begin
  25. if T[i]='M' then milk:=milk +F[i];
  26.  
  27. if T[i]='B' then food:=food +F[i];
  28.  
  29. if milk>=50 then begin if i<N-1 then begin K:=K+1; milk:=milk-50;end; end
  30. else
  31. if food>=80 then begin if i<N-1 then begin K:=K+1; food:=food-80;end; end;
  32.  
  33. end;
  34.  
  35. WriteLn(K);
  36.  
  37. end.
Success #stdin #stdout 0.01s 5308KB
stdin
5
150 M
1 B
1 B
1 B
1 B
stdout
3