君はまるで砂漠に咲く、一輪の花。

僕はその花に引き寄せられる蝶。

Codeforces Round #279 (Div. 2)

はい。
http://codeforces.com/contest/490

A. Team Olympiad

ざっくりと大意

・n人の学生がいる。\(t_i\)が1ならプログラミング、2なら数学、3なら保健体育?が得意。
・それぞれ1,2,3が得意な学生で3人組を作り、その並んでいる位置の3つの数を一行ずつ出力する??

方針のようなもの

・3人組を作れなくなるまで探す。

n=int(raw_input())
t=map(int,raw_input().split())
x=1
t1,t2,t3=[],[],[]
for i in t:
    if i==1: t1.append(x)
    if i==2: t2.append(x)
    if i==3: t3.append(x)
    x+=1
chk=0
ans=[]
while 1:
    if len(t1)==0 or len(t2)==0 or len(t3)==0:
        break
    ans.append((t1.pop(0),t2.pop(0),t3.pop(0)))
    chk+=1
print chk
if chk:
    for i in ans:
        print i[0],i[1],i[2]

学生が最大で5000人なのでリストを毎回先頭から探して抜き出した学生は数を0に変更して先頭から探しなおして〜〜とかは多分TLEになるので科目ごとに並んでる位置の情報を抜き出して組み合わせを作る。