Diff
checker
テキスト
テキスト
画像
ドキュメント
Excel
フォルダ
Legal
Enterprise
デスクトップ
料金
ログイン
Diffchecker デスクトップのダウンロード
テキスト比較
2 つのテキスト ファイルの違いを見つける
ツール
履歴
ライブエディター
未変更行を折りたたむ
折り返しなし
レイアウト
分割
統合
比較精度
スマート
単語
文字
シンタックスハイライト
構文を選択
無視
テキスト変換
最初の差分へ移動
入力を編集
Diffchecker Desktop
Diffcheckerを実行する最も安全な方法。Diffchecker Desktopアプリを入手:あなたの差分はコンピューターから出ることはありません!
Desktopを入手
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()
違いを見つける