grach

2016_August_28 Hospital

Sep 23rd, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Hospital
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine()); //период време
  14.                        
  15.             int threadpatients = 0;
  16.             int unthreadpatients = 0;
  17.             int doctors = 7;
  18.  
  19.             for (int i = 1; i <= n; i++)
  20.             {
  21.                 var patients = int.Parse(Console.ReadLine());
  22.  
  23.                 if ((i%3==0)&&(unthreadpatients>threadpatients))
  24.                 {
  25.                     doctors++;
  26.                 }
  27.                 if (patients>doctors)
  28.                 {
  29.                     threadpatients += doctors;
  30.                     unthreadpatients += patients - doctors;
  31.                 }
  32.                 else
  33.                 {
  34.                     threadpatients+=patients  ;
  35.                 }            
  36.             }          
  37.  
  38.             Console.WriteLine("Treated patients: {0}.", threadpatients);
  39.             Console.WriteLine("Untreated patients: {0}.", unthreadpatients);
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment