Diff
checker
텍스트
텍스트
이미지
문서
Excel
폴더
Legal
Enterprise
데스크톱
요금제
로그인
데스크톱 앱 다운로드
텍스트 비교
두 텍스트 파일의 차이점을 찾아보세요
도구
기록
실시간 편집
변경 없는 행 숨기기
줄바꿈 비활성화
레이아웃
나란히 보기
합쳐 보기
비교 단위
스마트
단어
글자
구문 강조
언어 선택
제외
텍스트 변환
첫 변경으로
수정
Diffchecker Desktop
가장 안전하게 Diffchecker를 사용하는 방법. 데스크톱 앱을 사용하면 비교 데이터가 외부로 전송되지 않습니다!
데스크톱 앱 받기
First and last submission
생성일
4년 전
비교 결과 만료 없음
초기화
내보내기
공유
설명
17 삭제
행
총
삭제
글자
총
삭제
이 기능을 계속 사용하려면 업그레이드해 주세요
Diff
checker
Pro
요금제 보기
69 행
복사
8 추가
행
총
추가
글자
총
추가
이 기능을 계속 사용하려면 업그레이드해 주세요
Diff
checker
Pro
요금제 보기
63 행
복사
복사
복사됨
복사
복사됨
# https://www.codechef.com/viewsolution/
60594129
# https://www.codechef.com/viewsolution/
60638735
복사
복사됨
복사
복사됨
# cook your dish here
import sys,os,io
import sys,os,io
import math
import math
from collections import defaultdict
from collections import defaultdict
복사
복사됨
복사
복사됨
def ii():
return int(input())
def li():
return list(map(int,input().split()))
if(os.path.exists('input.txt')):
sys.stdin = open("input.txt","r") ; sys.stdout = open("output.txt","w")
else:
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import bisect
import bisect
def lengthOfLIS(nums):
def lengthOfLIS(nums):
x = []
x = []
temp = [0]*(len(nums))
temp = [0]*(len(nums))
for i in range(len(nums)):
for i in range(len(nums)):
if not x:
if not x:
x.append(nums[i])
x.append(nums[i])
temp[i]=len(x)
temp[i]=len(x)
continue
continue
ind = bisect.bisect_left(x,nums[i])
ind = bisect.bisect_left(x,nums[i])
복사
복사됨
복사
복사됨
# replace bisect_left by bisect_right for longes non-dec subsequence
if ind==len(x):
if ind==len(x):
x.append(nums[i])
x.append(nums[i])
else:
else:
x[ind]=nums[i]
x[ind]=nums[i]
temp[i]=len(x)
temp[i]=len(x)
return temp
return temp
def lengthOfLDS(nums):
def lengthOfLDS(nums):
x = []
x = []
temp = [0]*(len(nums))
temp = [0]*(len(nums))
for i in range(len(nums)):
for i in range(len(nums)):
if not x:
if not x:
x.append(nums[i])
x.append(nums[i])
temp[i]=len(x)
temp[i]=len(x)
continue
continue
ind = bisect.bisect_left(x,nums[i])
ind = bisect.bisect_left(x,nums[i])
복사
복사됨
복사
복사됨
# replace bisect_left by bisect_right for longes non-dec subsequence
if ind==len(x):
if ind==len(x):
x.append(nums[i])
x.append(nums[i])
else:
else:
x[ind]=nums[i]
x[ind]=nums[i]
temp[i]=len(x)
temp[i]=len(x)
return temp[::-1]
return temp[::-1]
def solve():
def solve():
복사
복사됨
복사
복사됨
n =
ii(
)
n =
int(input()
)
l = li
()
l = li
st(map(int,input().split()))
a = lengthOfLIS(l)
a = lengthOfLIS(l)
for i in range(n):
for i in range(n):
l[i]=-l[i]
l[i]=-l[i]
l = l[::-1]
l = l[::-1]
b = lengthOfLDS(l)
b = lengthOfLDS(l)
ans = 0
ans = 0
for i in range(n-1):
for i in range(n-1):
ans=max(ans,a[i]+b[i+1])
ans=max(ans,a[i]+b[i+1])
print(ans)
print(ans)
복사
복사됨
복사
복사됨
t = 1
t =
ii(
)
t =
int(input()
)
for
_
in range(t):
for
i
in range(t):
solve()
solve()
복사
복사됨
복사
복사됨
저장된 비교 결과
원본
파일 열기
# https://www.codechef.com/viewsolution/60594129 # cook your dish here import sys,os,io import math from collections import defaultdict def ii(): return int(input()) def li(): return list(map(int,input().split())) if(os.path.exists('input.txt')): sys.stdin = open("input.txt","r") ; sys.stdout = open("output.txt","w") else: input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline import bisect def lengthOfLIS(nums): x = [] temp = [0]*(len(nums)) for i in range(len(nums)): if not x: x.append(nums[i]) temp[i]=len(x) continue ind = bisect.bisect_left(x,nums[i]) # replace bisect_left by bisect_right for longes non-dec subsequence if ind==len(x): x.append(nums[i]) else: x[ind]=nums[i] temp[i]=len(x) return temp def lengthOfLDS(nums): x = [] temp = [0]*(len(nums)) for i in range(len(nums)): if not x: x.append(nums[i]) temp[i]=len(x) continue ind = bisect.bisect_left(x,nums[i]) # replace bisect_left by bisect_right for longes non-dec subsequence if ind==len(x): x.append(nums[i]) else: x[ind]=nums[i] temp[i]=len(x) return temp[::-1] def solve(): n = ii() l = li() a = lengthOfLIS(l) for i in range(n): l[i]=-l[i] l = l[::-1] b = lengthOfLDS(l) ans = 0 for i in range(n-1): ans=max(ans,a[i]+b[i+1]) print(ans) t = 1 t = ii() for _ in range(t): solve()
수정본
파일 열기
# https://www.codechef.com/viewsolution/60638735 import sys,os,io import math from collections import defaultdict import bisect def lengthOfLIS(nums): x = [] temp = [0]*(len(nums)) for i in range(len(nums)): if not x: x.append(nums[i]) temp[i]=len(x) continue ind = bisect.bisect_left(x,nums[i]) if ind==len(x): x.append(nums[i]) else: x[ind]=nums[i] temp[i]=len(x) return temp def lengthOfLDS(nums): x = [] temp = [0]*(len(nums)) for i in range(len(nums)): if not x: x.append(nums[i]) temp[i]=len(x) continue ind = bisect.bisect_left(x,nums[i]) if ind==len(x): x.append(nums[i]) else: x[ind]=nums[i] temp[i]=len(x) return temp[::-1] def solve(): n = int(input()) l = list(map(int,input().split())) a = lengthOfLIS(l) for i in range(n): l[i]=-l[i] l = l[::-1] b = lengthOfLDS(l) ans = 0 for i in range(n-1): ans=max(ans,a[i]+b[i+1]) print(ans) t = int(input()) for i in range(t): solve()
비교하기