It was funny, especially #1 =)
it=gets.chomp.to_i;
p (it%2==0 and it!=2)?"YES":"NO";
Second task was pretty good, not same as my ugly code :)
d,sumTime=gets.split(" ");
d=d.to_i()
sumTime=sumTime.to_i()
i=0;
time=[];
maxTime=[];
full_count=0;
minSum=0;
maxSum=0;
while ggets=gets
x,y=ggets.split(" ");
x=x.to_i();
y=y.to_i();
full_count+=x;
minSum+=x;
maxSum+=y;
time[i]=x.to_i;
maxTime[i]=y.to_i;
i+=1;
end
if sumTime>maxSum or sumTime<minSum
puts 'NO';
else
i=0;
while full_count!=sumTime
if i==d
i=0;
end
if(maxTime[i]>time[i])
time[i]+=1;
full_count+=1;
else
next
end
i+=1;
end
puts 'YES';
p time.join(" ");
end
THIRD:
count=gets.chomp.to_i();
base={}
answer='';
out='';
count.times do
g=gets.chomp.to_s;
if base[g]!=1
base[g]=1;
out+="OK\n";
else
cnt=0;
while true
cnt+=1;
answer=g+cnt.to_s();
if base[answer]!=1
base[answer]=1
out+=answer+"\n";
break
end
end
end
end
puts out
Btw, second code hadn't worked right, anybody know why?