forked from hackerearthclub/CODE2RACE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request hackerearthclub#145 from ScifiDeath/BikeRace
Bike race
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import argparse | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("-f", dest="filepath", required=True) | ||
args = parser.parse_args() | ||
data = args.filepath | ||
|
||
with open(data) as reader: | ||
next(reader) | ||
N = M = L = 0 | ||
riders = [] | ||
for line in reader: | ||
line = line.strip().split() | ||
if len(line) == 2: | ||
riders.append(list(map(lambda x: int(x), line))) | ||
elif len(line) == 3: | ||
N, M, L = list(map(lambda x: int(x), line)) | ||
else: # assumes no empty lines | ||
i = 0 | ||
while sum([x[0] for x in riders if x[0] >= L]) < M: | ||
riders = [[x[0] + x[1], x[1]] for x in riders] | ||
i += 1 | ||
print(i) | ||
riders = [] | ||
i = 0 | ||
while sum([x[0] for x in riders if x[0] >= L]) < M: | ||
riders = [[x[0] + x[1], x[1]] for x in riders] | ||
i += 1 | ||
print(i) |