Upcoming SlideShare
×

разбор задач

256

Published on

0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total Views
256
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
5
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "разбор задач"

1. 1. Разбор задач:Аprogram z1;var N,i:integer;a,M,P:longint;beginreadln(N);M:=0; P:=0;for i:=1 to N dobeginread(a);if i mod 2=1 then M:=M+a*(i+1) else P:=P+a*(i+1);end;if M>P then write (Lost) else if M<P then write(Won) else write(?)end.
2. 2. Вprogram z2;const K=1000;var N,M,X,i:integer;Z:byte;Y,Post,Prod:longint;a:array[1..K] of longint;beginPost:=0; Prod:=0;Readln(N,M);for i:=1 to N do a[i]:=0;for i:=1 to M dobegin readln(X,Y,Z); if Z=0 then begin a[X]:=a[X]+Y; Post:=Post+Y; end else begin if a[x]>Y then begin a[X]:=a[X]-Y; Prod:=Prod+Y; end else begin Prod:=Prod+a[X];a[X]:=0; end; end;end;Writeln(Post, ,Prod);for i:=1 to N do Write(a[i], )end.
3. 3. Сprogram z3;var n,m,i,j,ves,T,k,l,o,p:longint;a:array[1..100]of longint;beginReadln(N,M);for i:=1 to N do read(a[i]);ves:=a[1]+a[2]+a[3];T:=0;if ves <M then T:=ves elsebegin i:=2; while (i<=n) and (T=0) do begin j:=i+1; while (j<=n) and (T=0) do begin o:=j+1; while (o<=n)and(T=0) do begin if ves<M then T:=ves; o:=o+1 end; j:=j+1; end; i:=i+1end;end;for k:=1 to n dofor j:=k+1 to n do for o:=j+1 to n do begin
4. 4. ves:=a[k]+a[j]+a[o]; if (ves>T) and (ves<=M) then T:=ves;end; Write(T)end.
5. 5. Dprogram zD;var A:array[1..3,1..100] of integer;{A[1,i]- w - komu kot zanes igruhkuA[2,i] - m - minutyA[3,i] - sekundy}t,tm,th,i,N,km, kh:integer;{tm, th - vremya reytinga devothek}{km, kh - kol-vo igrushekt - obshee vremya s konca}beginkm:=0; kh:=0;Readln(N);for i:=1 to N do {zapolnyaem massiv i shitaem kol-vo igrushek u kagdoj devothki}beginreadln(A[1,i], A[2,i], A[3,i]);if A[1,i]=1 then km:=km+1 else kh:=kh+1;end;tm:=0; th:=0; t:=48*60;for i:=n downto 1 do {shitaem reyting c konca v sekundah}begin if km>kh then tm:=tm+t-A[2,i]*60-A[3,i] else if kh>km then th:=th+t-A[2,i]*60-A[3,i]; if A[1,i]=1 then km:=km-1 else kh:=kh-1;t:=A[2,i]*60+A[3,i]end;writeln(tm div 60, ,tm mod 60);write(th div 60, ,th mod 60);end.
6. 6. Eprogram z5;var n,k,m,i,S:longint;a:array[1..1000000] of longint;function m1():longint;varbeginend;function m2():integer;varbeginend;beginReadln(N,K);for i:=1 to N doRead(a[i]);m:=a[1];for i:=2 to n do if a[i]>m then m:=a[i];m:=m div 2;S:=0;for i:=1 to n do if a[i]>m then S:=S+a[i]-m;l:=true;while l doif S>k then
7. 7. beginif S<k+7 then begin write(m); l:=false end else m:=m1;endelsebegin if S>k-7 then begin write (m); l:=false; end else m:=m2;end;m:=m-1;S:=0;for i:=1 to n do if a[i]>m then S:=S+a[i]-m;while S<K dobegins:=0;m:=m-1;for i:=1 to n do if a[i]>m then S:=S+a[i]-m;end;write (m);end.