add aloha/2025cherry set
This commit is contained in:
59
storage/aloha/py/2025cherry-div1-A.py
Normal file
59
storage/aloha/py/2025cherry-div1-A.py
Normal file
@@ -0,0 +1,59 @@
|
||||
import sys
|
||||
|
||||
input = sys.stdin.readline
|
||||
|
||||
|
||||
class FibonacciCoin:
|
||||
def __init__(self, n, arr):
|
||||
self.n = n
|
||||
self.arr = arr
|
||||
|
||||
def solve(self) -> list[int]:
|
||||
cnts: list[int] = []
|
||||
curr = [0] * 1_200_000
|
||||
if self.arr[0] == 1 or self.arr[0] == 2:
|
||||
curr[2] = 1
|
||||
else:
|
||||
curr[self.arr[0]] = 1
|
||||
cnts.append(1)
|
||||
for i in range(1, self.n):
|
||||
cnt = cnts[-1]
|
||||
if self.arr[i] == 1 or self.arr[i] == 2:
|
||||
curr[2] += 1
|
||||
if curr[2] == 2:
|
||||
curr[2] = 0
|
||||
curr[3] += 1
|
||||
else:
|
||||
cnt += 1
|
||||
t = 3
|
||||
else:
|
||||
curr[self.arr[i]] += 1
|
||||
t = self.arr[i]
|
||||
cnt += 1
|
||||
while True:
|
||||
if curr[t] >= 1 and curr[t - 1] >= 1:
|
||||
curr[t] -= 1
|
||||
curr[t - 1] -= 1
|
||||
curr[t + 1] += 1
|
||||
cnt -= 1
|
||||
t = t + 1
|
||||
elif curr[t] >= 1 and curr[t + 1] >= 1:
|
||||
s = min([curr[t], curr[t + 1]])
|
||||
curr[t] -= 1
|
||||
curr[t + 1] -= 1
|
||||
curr[t + 2] += 1
|
||||
cnt -= 1
|
||||
t = t + 2
|
||||
else:
|
||||
break
|
||||
cnts.append(cnt)
|
||||
return cnts
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
n = int(input())
|
||||
arr = list(map(int, input().split()))
|
||||
|
||||
solver = FibonacciCoin(n, arr)
|
||||
|
||||
print(*solver.solve(), sep=' ')
|
||||
33
storage/aloha/py/2025cherry-div1-C.py
Normal file
33
storage/aloha/py/2025cherry-div1-C.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import sys
|
||||
|
||||
input = sys.stdin.readline
|
||||
|
||||
|
||||
class ReverseSortTracer:
|
||||
def __init__(self, n, arr):
|
||||
self.n = n
|
||||
self.arr = arr
|
||||
|
||||
def sort_trace(self) -> list[tuple[int, int]]:
|
||||
qx = []
|
||||
sorted_arr = self.arr.copy()
|
||||
|
||||
for i in range(1, self.n):
|
||||
l = i
|
||||
r = sorted_arr.index(i) + 1
|
||||
for ptr in range((r - l + 1) // 2):
|
||||
sorted_arr[l + ptr - 1], sorted_arr[r - 1 - ptr] = \
|
||||
sorted_arr[r - 1 - ptr], sorted_arr[l + ptr - 1]
|
||||
qx.append((l, r))
|
||||
|
||||
return qx
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
n = int(input())
|
||||
arr = list(map(int, input().split()))
|
||||
|
||||
solved = ReverseSortTracer(n, arr).sort_trace()
|
||||
print(len(solved))
|
||||
for pair in solved:
|
||||
print(*pair)
|
||||
26
storage/aloha/py/2025cherry-div1-D.py
Normal file
26
storage/aloha/py/2025cherry-div1-D.py
Normal file
@@ -0,0 +1,26 @@
|
||||
import sys
|
||||
|
||||
input = sys.stdin.readline
|
||||
|
||||
|
||||
class ALOHAGames:
|
||||
def __init__(self):
|
||||
self.t = 1
|
||||
self.f = 0
|
||||
self.res_mineral = 4000
|
||||
self.res_propane = 3000
|
||||
|
||||
|
||||
# R1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("""8
|
||||
max(1,1)
|
||||
min(2,3)
|
||||
plus(1,1,1)
|
||||
plus(3,3,2)
|
||||
max(3,3)
|
||||
submit(1,1)
|
||||
minus(9,9,3)
|
||||
submit(3,3)""")
|
||||
19
storage/aloha/py/completed/2025cherry-div1-B.py
Normal file
19
storage/aloha/py/completed/2025cherry-div1-B.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import sys
|
||||
|
||||
input = sys.stdin.readline
|
||||
|
||||
|
||||
class SeongjunEncryption:
|
||||
def __init__(self, n, t):
|
||||
self.n = n
|
||||
self.t = t
|
||||
|
||||
def solve(self) -> bool:
|
||||
return self.t[0] == 'A' and self.t[-1] == 'B'
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
n = int(input())
|
||||
t = input().strip()
|
||||
|
||||
print("Yes" if SeongjunEncryption(n, t).solve() else "No")
|
||||
Reference in New Issue
Block a user