字符串题‘111222333’(python,一下子过了就没看了,现在有点慌,不知道是不是看错了): s = input() sList = [i for i in s] n = len(s) temp = 0 for i in range(1, n): if sList[i] == sList[i-1]: sList[i] = 'a' temp += 1 print(temp)
ac了第一道,第二道居然忘记把第一行的注释解开,真是个憨憨,一直通不过,结束了才发现,气死了, 附上第二题代码(大佬可以帮忙看看): let n = read_line(); let char1 = gets(200020); let char2 = gets(200020); let ch1 = char1.split(' ') let ch2 = char2.split(' ') // let n = 3 // let ch1 = [2,1,5] // let ch2 = [6,3,7]; let index = 0,step=0; let arr = Array(100000).fill(0); ch1.sort(); ch2.sort(); let len = ch2[ch2.length-1]; let max = 0 //确定每个时刻的的共有流行 for(let i=0; i< len; i++){ // console.log('22') //出现就加+ while(ch1[0] == i){ step++; if(max
看流星题(过了80%,python): n = int(input()) s = [int(i) for i in input().split()] t = [int(i) for i in input().split()] t_max = max(t) dp = [0] * (t_max + 1) for i in s: dp[i] += 1 for i in t: dp[i] -= 1 for i in range(1, len(dp)): dp[i] = dp[i] + dp[i-1] for i in range(n): if s[i] == t[i]: dp[s[i]] += 1 m = max(dp) temp = 0 list = [] for i in range(len(dp)): if dp[i] == m: temp += 1 list.append(dp[i]) if i != len(dp)-1 and dp[i+1] != m: temp += 1 for i in range(n): if s[i] == t[i] and i in list: temp -= 1 print(m, temp)