-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp4.cpp
53 lines (52 loc) · 849 Bytes
/
p4.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//Google code jam'22 qualification round Q2-3D Printing.
#include<iostream>
using namespace std;
int i,j,t,temp;
int MIN(int a,int b,int c)
{
int min=(a>b) ? b:a;
return (min>c) ? c:min;
}
int main()
{
int testc=1,test;
scanf("%d",&test);
while(testc<=test)
{
int arrout[4]={0,0,0,0},sum=1000000,arr[3][4];
for(i=0;i<3;i++)
{
for(j=0;j<4;j++)
{
scanf("%d",&arr[i][j]);
}
}
i=0;
while(sum!=0 && i<4)
{
t=MIN(arr[0][i],arr[1][i],arr[2][i]);
if(t>=1000000)
t=1000000;
if(sum<=t)
t=sum;
sum-=t;
arrout[i]=t;
i++;
}
printf("Case #%d: ",testc);
if(sum==0)
{
for(i=0;i<4;i++)
{
printf("%d ",arrout[i]);
}
}
else
{
printf("IMPOSSIBLE");
}
printf("\n");
testc++;
}
return 0;
}