Created
May 11, 2022 15:50
-
-
Save washingtonsoares/44f8bd19caa516089947b0beb7b2af0f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# https://www.beecrowd.com.br/judge/pt/problems/view/1222 | |
while True: | |
try: | |
wordsLength, maxLinesPerPage, maxCharPerLine = map(int, input().split(" ")) | |
shortStory = input() | |
lines = 0 | |
pages = 0 | |
words = shortStory.split(" ") | |
currentIndex = 0 | |
while currentIndex < wordsLength: | |
line = [] | |
lineSum = 0 | |
while currentIndex < wordsLength and (lineSum + len(words[currentIndex])) <= maxCharPerLine: | |
wordWithSpace = words[currentIndex] + " " | |
line.append(wordWithSpace) | |
lineSum += len(wordWithSpace) | |
currentIndex += 1 | |
currentIndex = currentIndex | |
lines += 1 | |
if (lines >= maxLinesPerPage or currentIndex == wordsLength): | |
lines = 0 | |
pages += 1 | |
print(pages) | |
except EOFError: | |
break | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment