RACE START
LOOP11 CALL INPUT
	LD GR0,GR0
	JMI IEND
	ADDA GR2,TOTAL,GR1  ; タイム
	ST GR2,TOTAL,GR1
	JUMP LOOP11
IEND LD GR3,=9
	LD GR0,=#7FFF ; 最大値
LOOP12 LD GR2,GR0
	LD GR4,=9
LOOP13 CPA GR2,TOTAL,GR4
	JPL CHANGE
	JUMP NEXT
CHANGE LD GR2,TOTAL,GR4 ; GR2<--新たなタイムの最小値
	LD GR1,GR4 ; GR1<-- そのチーム番号
NEXT SUBA GR4,=1
	JPL LOOP13 ;答　エ
	SRL GR2,3 ; 平均タイム
	CALL OUTPUT
	ST GR0,TOTAL,GR1 ;　処理済みとして最大値を設定
	SUBA GR3,=1
	JPL LOOP12 ;答　ウ
	RET
TOTAL DC 0,0,0,0,0,0,0,0,0,0 ;（チーム数＋１）個の領域
	END
;------------------
OUTPUT START
	RPUSH
	OR GR1,=#0030
	ST GR1,TEAM
	LAD GR3,TIME
	LD GR4,=0
	LD GR5,=3 ;
LOOP21 LD GR6,DIVISOR, GR4 ;
	LD GR7, =0 ;
LOOP22 CPA GR2,GR6
	JMI SETTIME
	SUBA GR2,GR6
	ADDA GR7,=1
	JUMP LOOP22 ;答　オ
SETTIME OR GR7,=#0030
	ST GR7,0,GR3
	ADDA GR4,=1
	ADDA GR3,=1
	SUBA GR5,=1
	JPL LOOP21 ;答　イ
	OR GR2,=#0030
	ST GR2,0,GR3
	OUT TEAM,LEN
	RPOP	
	RET
TEAM DS 1
	DC ' '
TIME DS 4
LEN DC 6
DIVISOR DC 600, 60, 10
	END
;----------------------
;題意に沿ってプログラムを簡単にするため
;個人別タイムは既に秒に変換済みにしてあります。
;GR1-->チーム番号、GR2-->秒数
;GR0-->正の値で戻る、-1で戻ると終了
INPUT START
	LD GR0,=1
	LD GR3,INDEX
	CPA GR3,=72
	JZE FIN
	LD GR4,GR3
	SRL GR4,3
	ADDA GR4,=1
	ST GR4,TEAMNR
	LD GR2,TEAM1,GR3
	LD GR1,GR4
	LAD GR3,1,GR3
	ST GR3,INDEX
	RET
FIN LD GR0,=-1
	RET
INDEX DC 0
TEAMNR DC 1
;MBRKAZU DC 8
;TEAMKAZU DC 9
TEAM1 DC 1620, 1730, 1840, 1950
      DC 2060, 2170, 2280, 2390
TEAM2 DC 1630, 1740, 1850, 2060
      DC 1642, 1724, 1845, 2104
TEAM3 DC 1701, 1823, 1797, 1900
      DC 2089, 2043, 1799, 1824
TEAM4 DC 1884, 1282, 1695, 1677
      DC 3056, 3157, 2795, 1844
TEAM5 DC 2087, 2312, 2915, 2507
      DC 1953, 2087, 2001, 1679
TEAM6 DC 2133, 1694, 1990, 2022
      DC 1901, 1784, 1953, 2139
TEAM7 DC 1867, 3498, 3328, 2041
      DC 1630, 1849, 3933, 1966
TEAM8 DC 3000, 3010, 3020, 3030
      DC 3040, 3050, 3060, 3070
TEAM9 DC 1884, 1282, 1695, 1677
      DC 3056, 3157, 2795, 1844
	END
;-----------------------

