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
2026 - PlatouK
(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 ver. 1 === <syntaxhighlight lang="python" line> # 2026 - PlatouK def validate_input(k, n, sequence): # Verifică dacă datele de intrare sunt corecte if not 1 <= k <= 100 or not 1 <= n <= 1000000 or not all(0 <= x <= 10000 for x in sequence): return False return True def find_longest_plateau(k, sequence): longest_plateau_length = 0 longest_plateau_element = None for i in range(len(sequence)): # Verifică dacă putem efectua operațiunea de extragere/inserare de cel puțin o dată if k >= i: # Extrage platoul din secvență plateau = [] j = i while j < len(sequence) and (not plateau or sequence[j] == plateau[0]): plateau.append(sequence[j]) j += 1 plateau_length = len(plateau) # Verifică dacă putem efectua operațiunea de extragere/inserare de cel puțin încă o dată if k >= i + plateau_length: # Inserează platoul în secvență și calculează lungimea platoului rezultat new_sequence = sequence[:i] + sequence[i+plateau_length:] for l in range(i, len(new_sequence)): new_sequence.insert(l, plateau[0]) k_left = k - (i + plateau_length) while k_left >= l + plateau_length: new_sequence = new_sequence[:l+plateau_length] + plateau + new_sequence[l+plateau_length:] k_left -= (l + plateau_length) result_plateau = [] j = 0 while j < len(new_sequence): # Calculează lungimea platoului format din elementul curent plateau = [] while j < len(new_sequence) and (not plateau or new_sequence[j] == plateau[0]): plateau.append(new_sequence[j]) j += 1 plateau_length = len(plateau) # Verifică dacă lungimea platoului este maximă if plateau_length > longest_plateau_length: longest_plateau_length = plateau_length longest_plateau_element = plateau[0] # Continuă căutarea în secvența următoare j += 1 return longest_plateau_length, longest_plateau_element if __name__ == "__main__": # Citire date de intrare k = int(input()) n = int(input()) sequence = list(map(int, input().split())) p = int(input()) # Verificare date de intrare if not validate_input(k, n, sequence): print("Datele nu corespund restricțiilor impuse.") else: # Calculează lungimea maximă a platoului sau elementul din care este format platoul longest_plateau_length, longest_plateau_element = find_longest_plateau(k, sequence) if p == 1: print("Datele sunt introduse corect.") print(longest_plateau_length) else: print("Datele sunt introduse corect.") print(longest_plateau_element) </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