Войти
или
Зарегистрироваться
Маркетплейс
Курсы
Учебник
Учебник 2.0
ОГЭ/ЕГЭ
Олимпиады
Рубрикатор
Компилятор
Онлайн Компилятор
Компилятор Python (lite)
Редактор HTML Code
Статья Автор:
Щурова Ольга
ЕГЭ-26
f=open('26.1.txt') k=int(f.readline()) cells=[[False,0]]*k n=int(f.readline()) v=[] v=f.readlines() for x in range(len(v)): v[x]=list(map(int,v[x].split())) #convert to desirable format v.sort(key=lambda row:(row[0],row[1])) cnt=0 for m in range(1,1441): #print(v[:30]) brd=0 for c in range(k): # cleaning if cells[c][1]==m-1: cells[c]=[False,0] while brd<len(v) and v[brd][0]==m: if [False,0] in cells: cnt+=1 pos=cells.index([False,0]) cells[pos]=[True,v[brd][1]] brd+=1 v=v[brd:] #print(cells) print(cnt,pos+1)
×
# сброс счётчиков! f=open('26_1.txt') #test n=int(f.readline()) v=list(f.readlines()) d={} for t in range(n): v[t]=list(map(int,v[t].split())) i=v[t][0] if i in d: d[i]+=[v[t][1]] else: d[i]=[v[t][1]] d[i]=sorted(list(set(d[i]))) mcnt=0 ans=0 num=0 for k in d: mas=d[k] cnt,mcnt=1,0 for x in range(1,len(mas)): if mas[x]==mas[x-1]+2: cnt+=1 else: mcnt=max(mcnt,cnt) cnt=1 mcnt=max(mcnt,cnt) if mcnt>ans: ans=mcnt num=k elif mcnt==ans: num=min(num,k) print(num,ans)
×
f=open('26_2.txt') #test n=int(f.readline()) v=list(f.readlines()) for t in range(n): v[t]=list(map(int,v[t].split())) time=[0]*1441 for x in range(n): cin,cout=v[x][0],v[x][1] time[cin]+=1 time[cout]-=1 cnt_nn=0 for pos in range(1440,0,-1): if time[pos]!=0: cnt_nn+=1 if cnt_nn==2: ans1=pos break cnt_n=0 ans2=0 for pos in range(1441): if time[pos]==0: cnt_n+=1 else: ans2=max(ans2,cnt_n+1) cnt_n=0 print(ans1,ans2)
×
def search(hall,m,k): ans=[] for c in range(k-1): for r in range(m): p1,p2=hall[r][c],hall[r][c+1] if p1+p2>0: if r>0: ans.append([r-1+1,c+1]) break return ans f=open('26-3.txt') s1=f.readline().split() for x in range(3): s1[x]=int(s1[x]) n,m,k=s1 hall=[] for x in range(m): hall.append([0]*k) v=f.readlines() for pos in range(n): x,y=map(int,v[pos].split()) x,y=x-1,y-1 hall[x][y]=1 ans=search(hall,m,k) ans.sort(key=lambda row: (-row[0],row[1])) print(ans) '''for x in range(m): print(hall[x])'''
×
f=open('26-4.txt') n,k=map(int,f.readline().split()) v=f.readlines() res=[] for x in range(len(v)): s=v[x].split() ide=int(s[0]) score=int(s[1])+int(s[2])+int(s[3]) add=int(s[4]) res.append([ide,score,add]) res.sort(key=lambda row:(-row[1],-row[2],row[0])) print(res[:k]) cnt=0
×
26-6
f=open('26-6.txt') # 26-6 6test lim,n=map(int,f.readline().split()) v=[] for x in f: v.append(int(x)) vs=sorted(v) s,i=0,0 res=[] while s+vs[i]<=lim: res.append(vs[i]) s+=vs[i] i+=1 kmax=len(res) cnt=0 for pos in range(n-1,kmax-1,-1): s=vs[pos] i=0 res=[s] while s+vs[i]<=lim: if pos!=i: res.append(vs[i]) s+=vs[i] i+=1 if len(res)<kmax:cnt+=1 #print(res,cnt) print(kmax,cnt) #162 788
×
def inp(v,f): for x in f: x=list(map(int,x.split())) id=x[0] x=x[1:] k1=sum(x) k2=0 for p in range(10): if x[p]>=0: k2+=x[p] k3=len(x)-x.count(0) v.append([id,k1,k2,k3]) def ap(nextr,v): last=nextr[-1] l=len(nextr) n=len(v) for pos in range(l,n): if v[pos][0]==last[0] and v[pos][1]==last[1] and v[pos][2]==last[2]: nextr.append(v[pos]) f=open('26-5.txt') n=int(f.readline()) v=[] inp(v,f) v.sort(key=lambda row:(-row[1],-row[2],-row[3],row[0])) #print(v[:3],v[-3:]) for pos in range(n): if v[pos][1]==0: break v=v[:pos] l=len(v) nextr=v[:l//3] last=nextr[-1] ap(nextr,v) print(last,v[-1])
×
Чтобы оставить комментарий нужна авторизация
Печать