Compare commits
4 Commits
Author | SHA1 | Date |
---|---|---|
|
c946a92701 | 1 year ago |
|
2b2079026a | 1 year ago |
|
321434f837 | 1 year ago |
|
8b36d3da1b | 1 year ago |
@ -1,2 +0,0 @@
|
||||
a=[0]*int(2e4)
|
||||
print(len(a))
|
@ -1,54 +0,0 @@
|
||||
from functools import cmp_to_key
|
||||
c=[[],[]]
|
||||
string=[[],[]]
|
||||
for i in range(2):
|
||||
a = eval(input())
|
||||
while a>0:
|
||||
s=input().split()
|
||||
s[1],s[2]=eval(s[1]),eval(s[2])
|
||||
c[i].append(s)
|
||||
string[i].append(s[0])
|
||||
a-=1
|
||||
def cmp(a,b):
|
||||
if a[1]>b[1]:
|
||||
return -1
|
||||
elif a[1]==b[1]:
|
||||
if a[2]<b[2] :
|
||||
return -1
|
||||
else:
|
||||
return 1
|
||||
else :
|
||||
return 1
|
||||
c[0]=sorted(c[0],key=cmp_to_key(cmp))
|
||||
# print(c[0])
|
||||
c[1]=sorted(c[1],key=cmp_to_key(cmp))
|
||||
# print(c[1])
|
||||
# m='123'
|
||||
# n='123'
|
||||
# print(m==n)
|
||||
st="lzr010506"
|
||||
s=set(string[0])&set(string[1])
|
||||
# for i in c[0]:
|
||||
# for j in c[1]:
|
||||
# if i[0] == j[0] :
|
||||
# s.append(j[0])
|
||||
# print(s)
|
||||
ans1=0
|
||||
ans2=0
|
||||
i=0
|
||||
while c[0][i][0] != st:
|
||||
# print(c[0][i][0])
|
||||
if c[0][i][0] in s:
|
||||
ans1+=1
|
||||
i+=1
|
||||
ans1= i+1-ans1
|
||||
i=0
|
||||
while c[1][i][0]!=st:
|
||||
# print(c[1][i][0])
|
||||
if c[1][i][0] in s:
|
||||
ans2+=1
|
||||
i+=1
|
||||
ans2=i+1-ans2
|
||||
# print(ans1,ans2)
|
||||
print(min(ans1,ans2))
|
||||
# print(c[0],'\n',c[1])
|
@ -1,18 +0,0 @@
|
||||
import heapq
|
||||
import ctypes
|
||||
a=int(input())
|
||||
b=input().split()
|
||||
for i in range(len(b)):
|
||||
b[i]=int(b[i])
|
||||
heapq.heapify(b)
|
||||
# print(b)
|
||||
sum=0
|
||||
while len(b) != 1:
|
||||
c,d=heapq.nsmallest(2,b)
|
||||
# heapq.heappop(b)
|
||||
# heapq.heappop(b)
|
||||
b.remove(c)
|
||||
b.remove(d)
|
||||
sum+=c+d
|
||||
heapq.heappush(b,c+d)
|
||||
print(sum)
|
@ -1,28 +0,0 @@
|
||||
import functools
|
||||
a,b =map(int, input().split(' '))
|
||||
nums=[]
|
||||
for i in range(b):
|
||||
m,n=map(int,input().split(' '))
|
||||
if m>n:continue;
|
||||
nums.append([m,n])
|
||||
def cmp(a,b):#升序
|
||||
if(a[0]>b[0]):
|
||||
return 1
|
||||
else :
|
||||
return -1#不变
|
||||
nums=sorted(nums,key=functools.cmp_to_key(cmp))
|
||||
# for i in nums:
|
||||
# print(i)
|
||||
sum = 0
|
||||
start,end=nums[0][0],nums[0][1]
|
||||
count=1
|
||||
while count<len(nums):
|
||||
if nums[count][0]>=start and nums[count][0]<=end:
|
||||
if end<=nums[count][1]:
|
||||
end=nums[count][1]
|
||||
else :
|
||||
sum+=end-start+1
|
||||
start=nums[count][0];end=nums[count][1]
|
||||
count+=1
|
||||
sum+=end-start+1
|
||||
print(a-sum+1)
|
@ -1,7 +0,0 @@
|
||||
a,b =map(int, input().split(' '))
|
||||
nums=[]
|
||||
for i in range(b):
|
||||
m,n=map(int,input().split(' '))
|
||||
nums.extend(range(m,n+1))
|
||||
nums=set(nums)
|
||||
print(a+1-len(nums))
|
Loading…
Reference in new issue