Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Bitnami MediaWiki
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
0747 - Turism
(section)
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Rezolvare== <syntaxhighlight lang="python" line="1"> #0747 Turism def conditii(nr_statii, nr_locuri, nr_opriri): restrictii = ( 0 < nr_statii <= 200, nr_statii <= nr_opriri <= 10_000, 2 < nr_locuri <= 100 ) return all(restrictii) def conditii_calatori(nr_statii, nr_calatori, calatori): if not nr_calatori == len(calatori): return False for c in calatori: if not 0 < c <= nr_statii: return False return True if __name__ == "__main__": scaune = [0] * 110 cost = 0 nr_statii, nr_locuri, nr_opriri = [int(x) for x in input().split()] if not conditii(nr_statii, nr_locuri, nr_opriri): print("Datele de intrare nu corespund restricțiilor impuse.") else: # Pentru fiecare oprire... for i in range(1, nr_opriri+1): # ...scădem 1 din fiecare scaun ocupat for j in range(1, nr_locuri+1): if scaune[j]: scaune[j] -= 1 # Inițializăm poziția primului scaun liber cu 1 poz = 1 rand_input = [int(x) for x in input().split()] nr_calatori = rand_input[0] calatori = rand_input[1:] if not conditii_calatori(nr_statii, nr_calatori, calatori): print("Datele de intrare nu corespund restricțiilor impuse.") exit(0) # Pentru fiecare călător... for cal in calatori: # ...căutăm primul scaun liber și îl ocupăm while poz <= nr_locuri and scaune[poz]: poz += 1 if poz <= nr_locuri: scaune[poz] = cal cost += cal print("Datele de intrare corespund restricțiilor impuse.") # Calculăm numărul de opriri necesare bazat pe numărul maxim de călători per stație maxim = scaune[0] for i in range(1, nr_locuri): if scaune[i] > maxim: maxim = scaune[i] rez = (nr_opriri - 1) // nr_statii + 1 if maxim: rez += (maxim - nr_opriri % nr_statii - 1) // nr_statii + 1 print(cost, rez) </syntaxhighlight>
Summary:
Please note that all contributions to Bitnami MediaWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Bitnami MediaWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width