Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fbe2979

Browse files
Add files via upload
1 parent 1edcaae commit fbe2979

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /