Submission #60982540


Source Code Expand

Copy
import bisect
n = int(input())
h = list(map(int, input().split()))
ans = 1
dp = [[1 for i in range(n)] for j in range(n)]
for i in range(n):
dp[0][i] = 1
for i in range(n):
for j in range(i + 1, n):
if h[i] == h[j]:
dp[j][j - i] += dp[i][j - i]
ans = max(dp[j][j - i], ans)
print(ans)
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
import bisect

n = int(input())
h = list(map(int, input().split()))
ans = 1
dp = [[1 for i in range(n)] for j in range(n)]
for i in range(n):
    dp[0][i] = 1
for i in range(n):
    for j in range(i + 1, n):
        if h[i] == h[j]:
            dp[j][j - i] += dp[i][j - i]
            ans = max(dp[j][j - i], ans)
print(ans)

Submission Info

Submission Time
Task C - Illuminate Buildings
User ikoya
Language Python (PyPy 3.10-v7.3.12)
Score 350
Code Size 338 Byte
Status AC
Exec Time 245 ms
Memory 153636 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 3
AC × 28
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
random_01.txt AC 143 ms 153384 KB
random_02.txt AC 92 ms 100300 KB
random_03.txt AC 130 ms 153380 KB
random_04.txt AC 66 ms 81452 KB
random_05.txt AC 142 ms 153432 KB
random_06.txt AC 90 ms 99992 KB
random_07.txt AC 132 ms 153352 KB
random_08.txt AC 65 ms 81168 KB
random_09.txt AC 141 ms 153184 KB
random_10.txt AC 119 ms 127120 KB
random_11.txt AC 130 ms 153560 KB
random_12.txt AC 66 ms 81504 KB
random_13.txt AC 141 ms 153548 KB
random_14.txt AC 119 ms 126884 KB
random_15.txt AC 134 ms 153320 KB
random_16.txt AC 90 ms 100512 KB
random_17.txt AC 144 ms 153636 KB
random_18.txt AC 122 ms 127332 KB
random_19.txt AC 133 ms 153536 KB
random_20.txt AC 110 ms 126908 KB
random_21.txt AC 241 ms 153156 KB
random_22.txt AC 236 ms 150968 KB
random_23.txt AC 245 ms 153364 KB
random_24.txt AC 128 ms 153272 KB
random_25.txt AC 60 ms 76604 KB
sample_01.txt AC 60 ms 76812 KB
sample_02.txt AC 59 ms 76296 KB
sample_03.txt AC 60 ms 76364 KB


2025-03-11 (Tue)
03:49:08 +00:00