File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed
Contests/AtCoder Beginner Contest 123/Explanations Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ The maximum distance between any two antenna is A[n] - A[1]
2
+
3
+ Checking only this is suffiicent.
4
+
5
+ ------
6
+
7
+ int main()
8
+ {
9
+ const int NO_OF_ANTENNA = 5;
10
+ vector <int> A(NO_OF_ANTENNA + 1);
11
+ int max_distance;
12
+ for(int i = 1; i <= NO_OF_ANTENNA; i++)
13
+ {
14
+ cin >> A[i];
15
+ }
16
+ cin >> max_distance;
17
+
18
+ int possible = (A[NO_OF_ANTENNA] - A[1] <= max_distance ? true : false);
19
+ cout << (possible ? "Yay!" : ":(") << "\n";
20
+
21
+ return 0;
22
+ }
Original file line number Diff line number Diff line change
1
+ Notice that every dish other than 1, will finish at a multiple of 10
2
+
3
+ Round up every element to the nearest multiple of 10, apart from the one with the smallest remainder modulo i
4
+
5
+ ------
6
+
7
+ int main()
8
+ {
9
+ const int NO_OF_DISHES = 5;
10
+ vector <int> A(NO_OF_DISHES + 1);
11
+ for(int i = 1; i <= NO_OF_DISHES; i++)
12
+ {
13
+ cin >> A[i];
14
+ }
15
+
16
+ int total_time = 0;
17
+ int time_saved = 0;
18
+ for(int i = 1; i <= NO_OF_DISHES; i++)
19
+ {
20
+ int remaining = (A[i]%10 != 0 ? 10 - A[i]%10 : 0);
21
+ time_saved = max(time_saved, remaining);
22
+
23
+ total_time += A[i] + remaining;
24
+ }
25
+ total_time -= time_saved;
26
+
27
+ cout << total_time << "\n";
28
+
29
+ return 0;
30
+ }
You can’t perform that action at this time.
0 commit comments