-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3_D_Printing.cpp
More file actions
59 lines (55 loc) · 1.34 KB
/
3_D_Printing.cpp
File metadata and controls
59 lines (55 loc) · 1.34 KB
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
54
55
56
57
58
59
#include <bits/stdc++.h>
using namespace std;
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define GOLD ((1 + sqrt(5)) / 2)
#define ll long long
const double PI = 3.14159265358979323846264338327950288419716939937510582097494459230;
void compute()
{
vector<vector<int>> colors(3, vector<int>(4));
vector<int> mn(4, 1e7);
int total = 1e6;
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 4; ++j)
cin >> colors[i][j];
for (int i = 0; i < 3; ++i)
for (int j = 0; j < 4; ++j)
mn[j] = min(mn[j], colors[i][j]);
if (accumulate(mn.begin(), mn.end(), 0) < total)
{
cout << "IMPOSSIBLE\n";
}
else
{
for (int i = 0; i < 4; ++i)
{
int t = min(mn[i], total);
total -= t;
cout << t << " ";
}
cout << "\n";
}
}
int main()
{
#ifdef debug
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("log.txt", "w", stderr);
#endif
int t, i = 1;
scanf("%d", &t);
while (i <= t)
{
cout << "Case #" << i << ": ";
compute();
++i;
}
#ifdef debug
fprintf(stdout, "\nTIME: %.3lf sec\n", (double)clock() / (CLOCKS_PER_SEC));
#endif
return 0;
}