Advertisement
apl-mhd

HousePaint

Dec 2nd, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.16 KB | None | 0 0
  1. /*
  2.  * main.cpp
  3.  *
  4.  * Copyright 2016 Antimatter <antimatter@antimatter-H81M-S2PV>
  5.  *
  6.  * This program is free software; you can redistribute it and/or modify
  7.  * it under the terms of the GNU General Public License as published by
  8.  * the Free Software Foundation; either version 2 of the License, or
  9.  * (at your option) any later version.
  10.  *
  11.  * This program is distributed in the hope that it will be useful,
  12.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  * GNU General Public License for more details.
  15.  *
  16.  * You should have received a copy of the GNU General Public License
  17.  * along with this program; if not, write to the Free Software
  18.  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  19.  * MA 02110-1301, USA.
  20.  *
  21.  *
  22.  */
  23.  
  24. void housePaint(int testCase){
  25.  
  26.  
  27.  
  28.  
  29.  
  30.     int i,j,n, min=1000, minfirst=1000, adrs, sum=0;
  31.     int  house[20][3];
  32.  
  33.    // int  house[20][3] = { {13,23,12},{77,36,64},{44,89,76},{31,78,45} };
  34.  
  35. for(n=0; n<testCase; n++){
  36.  
  37.         for(i = 0; i<4; i++){
  38.  
  39.             for(j =0; j<3; j++){
  40.  
  41.                     scanf("%d", &house[i][j]);
  42.  
  43.                     if(i == 0 && house[i][j] < minfirst){
  44.  
  45.                         minfirst = house[i][j];
  46.                         adrs = j;
  47.                        //printf("%d\n", minfirst);
  48.  
  49.                     }
  50.  
  51.  
  52.  
  53.                     //sum +=minfirst;
  54.                    // minfirst=0;
  55.  
  56.                      if( i >0 && j!=adrs && house[i][j] < min){
  57.  
  58.  
  59.                             min = house[i][j];
  60.                             adrs=j;
  61.  
  62.                            // printf("%d\n", min);
  63.  
  64.                     }
  65.  
  66.  
  67.  
  68.                 }
  69.  
  70.                 if(i>0){
  71.                    sum += min;
  72.                 }
  73.                  //printf("min first =%d\n", minfirst);
  74.                  sum += minfirst;
  75.                  min = 1000;
  76.                  minfirst=0;
  77.  
  78.             }
  79.  
  80.  
  81.     printf("Case %d: %d\n", n+1, sum);
  82.  
  83. }
  84.  
  85. }
  86.  
  87. #include <stdio.h>
  88.  
  89. int main(int argc, char **argv)
  90. {
  91.  
  92.     int testCase;
  93.     scanf("%d",&testCase);
  94.     housePaint(testCase);
  95.  
  96.     return 0;
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement