提出 #73479647
ソースコード 拡げる
import sys
import string
import math
import bisect
import os
import heapq
import operator
from io import BytesIO, IOBase
from heapq import heappop,heappush
from functools import lru_cache,cache
from copy import copy,deepcopy
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,accumulate
from array import array
INF = float('inf')
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._file = file
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = sys.stdin.buffer.readline
ask = lambda *x:print('?',*x,flush=True)
reply = lambda *x:print('!',*x,flush=True)
RI = lambda: int(sys.stdin.readline())
RF = lambda: float(sys.stdin.readline())
RS = lambda: sys.stdin.readline().strip()
RFF = lambda: map(float, sys.stdin.readline().split())
RII = lambda: map(int, sys.stdin.readline().split())
RSS = lambda: map(str, sys.stdin.readline().strip().split())
RIL = lambda: list(RII())
RFL = lambda: list(RFF())
RSL = lambda: list(RSS())
from types import GeneratorType
def bootstrap(f, stack=[]):
def wrappedfunc(*args, **kwargs):
if stack:
return f(*args, **kwargs)
else:
to = f(*args, **kwargs)
while True:
if type(to) is GeneratorType:
stack.append(to)
to = next(to)
else:
stack.pop()
if not stack:
break
to = stack[-1].send(to)
return to
return wrappedfunc
def main():
n = RI()
a = RIL()
dp = defaultdict(lambda :-INF)
ans = 0
for i in range(n):
dp[a[i]] = max(dp[a[i]-1]+1,1)
ans = max(ans,dp[a[i]])
print(ans)
if __name__ == '__main__':
main()
提出情報
| 提出日時 |
|
| 問題 |
D - Max Straight |
| ユーザ |
x3x3 |
| 言語 |
Python (PyPy 3.11-v7.3.20) |
| 得点 |
400 |
| コード長 |
3442 Byte |
| 結果 |
AC |
| 実行時間 |
192 ms |
| メモリ |
174148 KiB |
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
400 / 400 |
| 結果 |
|
|
| セット名 |
テストケース |
| Sample |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All |
00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt |
| ケース名 |
結果 |
実行時間 |
メモリ |
| 00_sample_00.txt |
AC |
115 ms |
108920 KiB |
| 00_sample_01.txt |
AC |
114 ms |
108604 KiB |
| 00_sample_02.txt |
AC |
115 ms |
109000 KiB |
| 01_random_00.txt |
AC |
114 ms |
108984 KiB |
| 01_random_01.txt |
AC |
114 ms |
108728 KiB |
| 01_random_02.txt |
AC |
114 ms |
108788 KiB |
| 01_random_03.txt |
AC |
160 ms |
174148 KiB |
| 01_random_04.txt |
AC |
159 ms |
159980 KiB |
| 01_random_05.txt |
AC |
161 ms |
165700 KiB |
| 01_random_06.txt |
AC |
139 ms |
137364 KiB |
| 01_random_07.txt |
AC |
192 ms |
166524 KiB |
| 01_random_08.txt |
AC |
130 ms |
121868 KiB |
| 01_random_09.txt |
AC |
115 ms |
108944 KiB |
| 01_random_10.txt |
AC |
148 ms |
145628 KiB |
| 01_random_11.txt |
AC |
147 ms |
146132 KiB |
| 01_random_12.txt |
AC |
121 ms |
111216 KiB |
| 01_random_13.txt |
AC |
149 ms |
145876 KiB |
| 01_random_14.txt |
AC |
119 ms |
109712 KiB |
| 01_random_15.txt |
AC |
148 ms |
145968 KiB |
| 01_random_16.txt |
AC |
133 ms |
127900 KiB |
| 01_random_17.txt |
AC |
161 ms |
151216 KiB |
| 01_random_18.txt |
AC |
164 ms |
156724 KiB |
| 01_random_19.txt |
AC |
163 ms |
156924 KiB |
| 01_random_20.txt |
AC |
150 ms |
154072 KiB |
| 01_random_21.txt |
AC |
166 ms |
155684 KiB |
| 01_random_22.txt |
AC |
122 ms |
112212 KiB |