mickypinata

PROG-T1012: Silly Bakery

Sep 17th, 2021
792
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int one, threeF, half, oneF, oneE;
  5.  
  6. int main(){
  7.  
  8.     int n;
  9.     scanf("%d", &n);
  10.     for(int i = 1; i <= n; ++i){
  11.         int a, b, c, d, e;
  12.         scanf("%d%d%d%d%d", &a, &b, &c, &d, &e);
  13.         one += a;
  14.         threeF += b;
  15.         half += c;
  16.         oneF += d;
  17.         oneE += e;
  18.     }
  19.     int sum = 0;
  20.     sum += oneE / 8;
  21.     oneE %= 8;
  22.     oneF += (oneE + 1) / 2;
  23.     int fuse = min(threeF, oneF);
  24.     threeF -= fuse;
  25.     oneF -= fuse;
  26.     one += fuse;
  27.     half += (oneF + 1) / 2;
  28.     sum += (half + 1) / 2;
  29.     sum += threeF;
  30.     sum += one;
  31.     cout << sum;
  32.  
  33.     return 0;
  34. }
  35.  
RAW Paste Data