. ­ - ­ , .

­ . - .

. ­ ­ .

­ , . .

. ­ .

­ : , , .

¯ ¯

¯ ¯



¯ ¯

̠

: ­ - , - , - .


 
 
 
 


­ ­

­ ­

­ ­
̠
. , .
- . , ­ :




300000


240000


120000

 
­ .

.
:
(D1, ..., DN) - ,
D = [Fam, , Z] - ,
Fam - , D1-
, S0
= 0
Z - . Sk = Sk-1*(k-l )/k + Zk/k
: Zcpe - . [k=(l...N)]
:
Zcpe = (Z1 + Z2
+ ... + ZN)/N. Zcpe = SN
: N > 0.
, ­. . .
k = 1
S1=S0(1 - 1)/1 +Z1/1 =Z1/1.
k = 2
S2
= S1(2 - 1)/2 + Z2/2 = Z1/2 + Z2/2.
k = 3
S3 = S2(3 - 1)/3 + Z3/3 = (Z1 + Z2)/3 + Z3/3.
, k-
Sk
= (Z1 + ... + Zk-1)/k.


. , (k-l)-ro :
Sk-1
= (Z1 + ... + Zk-1)/(k-l).
k-e
Sk = Sk-1(k-l)/k + Zk/k =
= (Z1 + ... + Zk-1)/(k-l)×(k-l)/k + Zk/k = (Z1 + ... + Zk-1)/k + Zk/k.
. , ­ k = 1, 2,..., N. , k = N
SN
= (Z1 + ... + ZN-1)/N + ZN/N = (Z1 + ... + ZN)/N.
, Z1, Z2, ..., ZN.
, data.

: dan: '
{<> <> </>}* data ,, 300000
{...................} data ,, 240000
/= <Zcpe> data ,, 120000
data , , 0
, .

໠ '
cls
( :) ? :
s
:= 0: k := 0 s = 0: k = 0
렠 do


(fam$, dl$, zpl) read fam$, dl$, zpl
fam$ = 䠠 if fam$ = then exit do
(fam$, dl$, z) ? fam$; dl$; z
k
:= k + 1 k = k + 1
s
:= s*(k - 1)/k + z/k s = s*(k - 1)/k + z/k
렠 loop
zsr = s zsr = s
( 3/nama=,zsr) ? /=; zsr
end
­ .



( :) :
s := 0: k := 0 S0 = 0 [ k = 0 ]

(fam$, dl$, z)
fam$ =
(fam$, dl$, z) <famk> <dlk> <zk> }*
k:=k + 1 [ k= (1...N) ]
s := s*(k - 1)/k + z/k sk = sk - 1×(k - 1)/k + zk/k

zsr
= s zsr = sN
( /nama=,zsr) /= <zsr>

­ - .
. , ­ :



𠠠 -


8000
3

4000
2

1000
20

.


.
:
(D1, ...,
DN) - ,
D = [Tov, C, M] - , s0 = 0
Tov - , - , k = 1 N
- , sk
= sk-1 + kk
: k = 1
Sum - , m1
= 1111
TovMax - 頠 c kk > mk-1
.
: mk
= kk
Sum = C1M1 + 22
+ ... + NN,
TovMax: C×M = (11, ... ,NN).
:
N > 0.
, . , ­. k = 1
s1
= s0 + 11 = 1M1,
max1
= 11.
­:
s2
= s1 + 22 = C1M1
+ 22,
max2 = 22, 22 > max1 = (m1, 22),
max1, 22
£ max1 = (m1, 22).
­ :
sk
= sk-1 + CkMk = C1M1 + + CkMk,
maxk
= Max(maxk-1, kk) = (11, ..., kk).
, k-1:
sk-1
=C1M1 +...+ Ck-1Mk-1,
maxk-1
= Max (C1M1, ,Ck-1Mk-1),
sk mk:


sk
= sk-1 + CkMk = C1M1 + Ck-1Mk-1 + CkMk,
maxk
= Max(maxk-1, kk) = (11, ..., kk).
k = 1, 2, ..., N. k = N :
sN
= sN-1 + CNMN = C1M1 + + CNMN,
maxN
= Max(maxN-1, NN) = Max(C1M1, ... , NN).
. , ­ .
data.
 
 
 



𠠠 ࠠ -
<1> <1> <1> * dan: '
.... ... data , 8000, 3
= <Sum> data , 4000, 2
젠 data , 1000, 20
<> <> data , 0, 0
.

컠 '

ls
( ) ?
( -) ? -
s := 0; k = 0 s = 0: k = 0
렠 do


(, , ) read tv$, , m
= 䠠 if tv$ = then exit do
k := k + 1 k = k + 1
(, , ) ? fv$; ; m
s :=s + cm s= s + c(m
k = 1  if k = 1 then
max
:= c×m max = c×m
ToMax
:= ⠠ $ = tv$
c(m > max  elseif c(m > max then
max
:= c×m max = c×m
ToMax := ⠠ TM = tv$
蠠 end if
렠 loop
(cya=,s) ? cya=,s
() ?
(ToMax, max) ? TM$, max
end
 
.
 
 
 
 
 
 
 
 
 
 
 



( )
( -) -


s :=0; k = 0 s0 =0 [k = 0]

(, , )
=
k:=k+1 [k= 1,2,...,N]
(, , ) { <> <> <m> }*
s := s + ×򠠠 sk = sk-1 + ck×mk
k =1  k = 1

:= c×m max1 = c1×m1,

:= ⠠ ToMa1 = 1
u c×m >  k×mk
> m

:= ×򠠠 mk
= k×mk

:= ⠠ k
= k


(=, s) ca = <sN>
()
(, ) <ToMaxN> <maxN>

, . .
, - . , , .
-
. , - :
= - .
, : - :
 





3000

200

1200

120

2000

60

600

30

50


­.

.
: S = Sd - Sr
D = (1, ..., N) - , Sd = N
R = (1, ..., ) - , k = k-1 + dk
= (, d), [k = (1...N)]
= (, r). 0
= 0
.:
S - . Sr = bM
: bi = bi-1 + ri
S = Sum (d1, , dN) - Sum (r1, .... rM). [i =
(1 ... M)]
: N, M > 0. b0
= 0
data, ­ - .


'doch: '
: data , 300000
<k>
<dk> * data , 120000
... ... data , 200000
= <Sd> data , 0
:
<k> <rk> * rash: '


... ... data , 200000
= <Sd> data , 120000
= <S> data , 60000
data , 0
:
軠 '
cls
( )
?
( :) ? :
_⠠ gosub dchs '
(=, Sd) ? =, Sd
( :) ? :
_⠠ gosub rashs '
( =, Sr) ? =, Sr
S
:= Sd - Sr S = Sd - Sr
(=, S) ? =, S
end
⻠ dchs: '
'
_⠠ restore doch '
Sd := 0 Sd = 0
렠 do
(, d) read namS, d

= if nam$ = then exit do
(, d) ? nam$, d


Sd =
Sd + d Sd = Sd + d
렠 loop
return
⻠ rashs '
'
_⠠ restore rach '
Sr := 0 Sr = 0
렠 do
(, r) read stat$, r

= if st$ = then exit do
(, r) ? st$, r
Sr =
Sr + r Sr = Sr + r
렠 loop
return

:


: Sd0
= 0 [k = 0] Sr0
= 0 [i = 0]
<_>
= <Sd>
: [k =(1...N)] [i =(1...M)]
<_> <k> <dk> <1> <r1>
= < Sr> Sdk
= Sd/k-l/+dk Sri
== Sri-1 + ri
{ S = Sd - Sr
= <S>
: .


:
Sd0 = 0,
Sd1 = Sd0 + d1 = d1,
Sd2 = Sd1
+ d2 = d1
+ d2.
,
Sdk = Sdk-1 + dk = d1 + d2 + ... + dk-1 + dk.
.
SdN
= d1 + d2
+ ... + dN-1 + dN.
, - .
­ :
Sr0
= 0,
Sr1 = Sr0 + r1
= r1,
Sr2 = Sr1
+ r2 = r1 + r2
:
Sri
= Sri-1 + ri = r1
+ r2 +... + ri-1+ ri.
. ­ :
SrM = r1 + r2 + ... + rM-1+ rM.
, .
S = Sd - Sr.
­ ­
S = Sd - Sr = (d1
+ d2 + ... + dN) - (r1 + r2 + ... + rM).
. , ­ .

1. ?
2. ?
3. ?
4. ?
5. ?
6. ?

1. . ( - ) ­. , .
2. N D (N D - 1, 2, ....


N). . , .
3. N ­ (N , ). . , .
4. N (N - ). . , .
5. N (N, ). ­ , . ( ), ( , ) ( , ) .