6 kyu
Chaser's schedule
124 of 1,075RealSup
Description:
A runner, who runs with base speed s
with duration t
will cover a distances d
: d = s * t
However, this runner can sprint for one unit of time with double speed s * 2
After sprinting, base speed s
will permanently reduced by 1
, and for next one unit of time runner will enter recovery phase and can't sprint again.
Your task, given base speed s
and time t
, is to find the maximum possible distance d
.
Input:
1 <= s < 1000
1 <= t < 1000
Example:
Given s = 2
and t = 4
.
We could schedule when runner should sprint so we could get these possible sequences:
Seq.: RRRR => s + s + s + s => 2 + 2 + 2 + 2 = 8 Seq.: RRRS => s + s + s + s*2 => 2 + 2 + 2 + 2*2 = 10 Seq.: RRSR => s + s + s*2 + (s-1) => 2 + 2 + 2*2 + (2-1) = 9 Seq.: RSRR => s + s*2 + (s-1) + (s-1) => 2 + 2*2 + (2-1) + (2-1) = 8 Seq.: RSRS => s + s*2 + (s-1) + (s-1)*2 => 2 + 2*2 + (2-1) + (2-1)*2 = 9 Seq.: SRRR => s*2 + (s-1) + (s-1) + (s-1) => 2*2 + (2-1) + (2-1) + (2-1) = 7 Seq.: SRRS => s*2 + (s-1) + (s-1) + (s-1)*2 => 2*2 + (2-1) + (2-1) + (2-1)*2 = 8 Seq.: SRSR => s*2 + (s-1) + (s-1)*2 + (s-1-1) => 2*2 + (2-1) + (2-1)*2 + (2-1-1) = 7 Where: - R: Normal Run / Recovery - S: Sprint
Based on above sequences, the maximum possible distance d
is 10
.
Enjoy!
Logic
Algorithms
Similar Kata:
Stats:
Created | May 25, 2022 |
Published | May 25, 2022 |
Warriors Trained | 7693 |
Total Skips | 401 |
Total Code Submissions | 16829 |
Total Times Completed | 1075 |
C# Completions | 124 |
JavaScript Completions | 286 |
Python Completions | 337 |
Java Completions | 181 |
Ruby Completions | 34 |
Go Completions | 36 |
SQL Completions | 57 |
C Completions | 63 |
Rust Completions | 50 |
PowerShell Completions | 9 |
VB Completions | 6 |
Crystal Completions | 7 |
Lua Completions | 10 |
Pascal Completions | 4 |
Haskell Completions | 8 |
Total Stars | 236 |
% of votes with a positive feedback rating | 93% of 183 |
Total "Very Satisfied" Votes | 162 |
Total "Somewhat Satisfied" Votes | 16 |
Total "Not Satisfied" Votes | 5 |
Total Rank Assessments | 12 |
Average Assessed Rank | 5 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 7 kyu |