daily pastebin goal
45%
SHARE
TWEET

Untitled

a guest Dec 14th, 2018 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. using namespace std;
  4. ifstream fin("mixmilk.in");
  5. ofstream fout("mixmilk.out");
  6. using namespace std;
  7. int main()
  8. {
  9.     int a[3], b[3];
  10.     fin >> b[0] >> a[0] >> b[1] >> a[1] >> b[2] >> a[2];
  11.     int k = 0, temp = 0;
  12.     for (int i = 1; i <= 100; i++)
  13.     {
  14.         if (b[(k + 1) % 3] >= a[k % 3] + a[(k + 1) % 3])
  15.         {
  16.             a[(k + 1) % 3] += a[k % 3];
  17.             a[k % 3] = 0;
  18.         }
  19.         else
  20.         {
  21.             temp = b[(k+1) % 3] - a[(k+1) % 3];
  22.             a[(k + 1) % 3] += temp;
  23.             a[k % 3] -= temp;
  24.         }
  25.         k++;
  26.     }
  27.  
  28.     fout << a[0] << endl << a[1] << endl << a[2];
  29. }
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