File tree 1 file changed +38
-0
lines changed
2022/Contests/Div 2/792/Explanations
1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ When we want to maximize the number of buses, we will try to maximise the number of 4's.
2
+ While trying to minimize, we will try to maximize the number of 6's.
3
+
4
+ There is no answer possible if N = 1, 3 (mod 4).
5
+
6
+ There are only 2 cases where an answer exists.
7
+ N = 0, 2 (mod 4)
8
+
9
+ -----
10
+
11
+ void solve()
12
+ {
13
+ long long no_of_wheels;
14
+ cin >> no_of_wheels;
15
+
16
+ long long minimum, maximum;
17
+ switch(no_of_wheels%4)
18
+ {
19
+ case 0: maximum = no_of_wheels/4;
20
+ minimum = 2*(no_of_wheels/12) + (no_of_wheels%12 == 6 ? (no_of_wheels%12)/6 : (no_of_wheels%12)/4);
21
+ break;
22
+
23
+ case 2: if(no_of_wheels == 2)
24
+ {
25
+ cout << "-1\n";
26
+ return;
27
+ }
28
+ maximum = 1 + (no_of_wheels - 6)/4;
29
+ no_of_wheels -= 6;
30
+ minimum = 1 + 2*(no_of_wheels/12) + (no_of_wheels%12 == 6 ? (no_of_wheels%12)/6 : (no_of_wheels%12)/4);
31
+ break;
32
+
33
+ default: cout << "-1\n";
34
+ return;
35
+ }
36
+
37
+ cout << minimum << " " << maximum << "\n";
38
+ }
You can’t perform that action at this time.
0 commit comments