feat: added alternative python solutions.
This commit is contained in:
@@ -43,7 +43,7 @@
|
||||
},
|
||||
"solutions": {
|
||||
"main-ac": "ac.cpp",
|
||||
"alternative-ac": [],
|
||||
"alternative-ac": ["alternative-ac.py"],
|
||||
"wrong-answer": [],
|
||||
"time-limit": ["TLE.cpp"],
|
||||
"time-limit-or-ac": [],
|
||||
|
||||
27
vacations/src/alternative-ac.py
Normal file
27
vacations/src/alternative-ac.py
Normal file
@@ -0,0 +1,27 @@
|
||||
n = int(input())
|
||||
days = list(map(int, input().split()))
|
||||
|
||||
INF = float('inf')
|
||||
dp = [[INF] * 3 for _ in range(n)]
|
||||
|
||||
has_competition = lambda a: a & 1
|
||||
has_gym = lambda a: a & 2
|
||||
|
||||
dp[0][0] = 1
|
||||
|
||||
if has_competition(days[0]):
|
||||
dp[0][1] = 0
|
||||
|
||||
if has_gym(days[0]):
|
||||
dp[0][2] = 0
|
||||
|
||||
for i in range(1, n):
|
||||
dp[i][0] = min(dp[i-1][0], dp[i-1][1], dp[i-1][2]) + 1
|
||||
|
||||
if has_competition(days[i]):
|
||||
dp[i][1] = min(dp[i-1][0], dp[i-1][2])
|
||||
|
||||
if has_gym(days[i]):
|
||||
dp[i][2] = min(dp[i-1][0], dp[i-1][1])
|
||||
|
||||
print(min(dp[n-1]))
|
||||
Binary file not shown.
@@ -5,8 +5,6 @@
|
||||
\usepackage{url}
|
||||
\pagenumbering{gobble}
|
||||
\usepackage{hyperref}
|
||||
\usepackage{graphicx}
|
||||
\input{statement/preamble.tex}
|
||||
|
||||
\title{ Tutorial: Férias}
|
||||
\author{Codeforces 363 (Div. 1)}
|
||||
|
||||
Binary file not shown.
@@ -26,7 +26,6 @@ A segunda linha contém \(n\) inteiros \(a_1, a_2, \dots, a_n\) (\(0 \le a_i \le
|
||||
A saída consiste de um único número inteiro, o número mínimo possível de dias em que Miguel terá que descansar, obedecendo à restrição de não repetir a mesma atividade em dias consecutivos.
|
||||
|
||||
\ExemploEntrada
|
||||
|
||||
\begin{Exemplo}
|
||||
\texttt{4} & \texttt{2}\\
|
||||
\texttt{1~3~2~0} & \\
|
||||
|
||||
Reference in New Issue
Block a user