Diff
checker
Texte
Texte
Images
Documents
Excel
Dossiers
Legal
Enterprise
Application de bureau
Prix
Se connecter
Télécharger Diffchecker Desktop
Comparer le texte
Trouver la différence entre deux fichiers texte
Outils
Historique
Éditeur live
Cacher identiques
Sans retour à la ligne
Vue
Divisé
Unifié
Niveau de précision
Intelligent
Mot
Caractère
Coloration syntaxique
Choisir la syntaxe
Ignorer
Transformer le texte
Aller au premier écart
Modifier l'entrée
Diffchecker Desktop
La façon la plus sécurisée d'utiliser Diffchecker. Obtenez l'application Diffchecker Desktop : vos diffs ne quittent jamais votre ordinateur !
Obtenir Desktop
First and last submission
Créé
il y a 4 ans
Le diff n'expire jamais
Effacer
Exporter
Partager
Expliquer
17 suppressions
Lignes
Total
Supprimé
Caractères
Total
Supprimé
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
69 lignes
Copier tout
8 ajouts
Lignes
Total
Ajouté
Caractères
Total
Ajouté
Pour continuer à utiliser cette fonctionnalité, passez à
Diff
checker
Pro
Voir les prix
63 lignes
Copier tout
Copier
Copié
Copier
Copié
# https://www.codechef.com/viewsolution/
60594129
# https://www.codechef.com/viewsolution/
60638735
Copier
Copié
Copier
Copié
# cook your dish here
import sys,os,io
import sys,os,io
import math
import math
from collections import defaultdict
from collections import defaultdict
Copier
Copié
Copier
Copié
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])
Copier
Copié
Copier
Copié
# 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])
Copier
Copié
Copier
Copié
# 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():
Copier
Copié
Copier
Copié
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)
Copier
Copié
Copier
Copié
t = 1
t =
ii(
)
t =
int(input()
)
for
_
in range(t):
for
i
in range(t):
solve()
solve()
Copier
Copié
Copier
Copié
Différences enregistrées
Texte d'origine
Ouvrir un fichier
# 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()
Texte modifié
Ouvrir un fichier
# 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()
Trouver la différence