Submission #1215087


Source Code Expand

def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.to_s.chomp.split(" ").map(&:to_f)end
def inps() a=gets.to_s.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.to_s.chomp.split(" ").map{|u|u.to_i}end
n,k=inp
a=inp
ss=na(0,"")
 
n.times do |i|
  ss.push(inps[0])
end
ni = na(0,"")
a.sort!.each do |d|
  ni.push(ss[d-1])
end
a.reverse_each do |d|
  ss.delete_at(d-1)
end
max = ""
min = ""
ni.sort!
ss.each do |s|
  if(s < ni[0])
    if(min =="")
      min = s
    elsif(s > min)
      min = s
    end
  elsif(s > ni[-1])
    if(max =="")
      max = s
    elsif(s < max)
      max = s
    end
  else
    puts -1
    exit
  end
end
drf1=""
drf2=""
if(min != "")
  x=0
  len=[min.size,ni[0].size].min
  while true
    if(x == len)
      drf1 += ni[0][x]
      break
    end
    drf1 += ni[0][x]
    break if(ni[0][x] != min[x])
    x+=1
  end
end
if(max != "")
  if(max != "")
    x=0
    len=[max.size,ni[-1].size].min
    while true
      if(x == len)
        break
      end
      drf2 += ni[-1][x]
      break if(ni[-1][x] != max[x])
      x+=1
    end
  end
end
puts (drf1.size > drf2.size)? drf1 : drf2

Submission Info

Submission Time
Task C - 検索
User zazaboon
Language Ruby (2.3.3)
Score 400
Code Size 1548 Byte
Status AC
Exec Time 249 ms
Memory 79152 KB

Compile Error

./Main.rb:2: warning: assigned but unused variable - a
./Main.rb:3: warning: assigned but unused variable - a
./Main.rb:11: warning: assigned but unused variable - a
./Main.rb:43: warning: ambiguous first argument; put parentheses or a space even after `-' operator
./Main.rb:12: warning: assigned but unused variable - k

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 30
Set Name Test Cases
Sample sample1.txt, sample2.txt, sample3.txt
All sample1.txt, sample2.txt, sample3.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in2.txt, in20.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt, long.txt, long2.txt, sample1.txt, sample2.txt, sample3.txt, long.txt, long2.txt
Case Name Status Exec Time Memory
in1.txt AC 10 ms 2044 KB
in10.txt AC 9 ms 2044 KB
in11.txt AC 22 ms 2812 KB
in12.txt AC 8 ms 2044 KB
in13.txt AC 9 ms 2044 KB
in14.txt AC 10 ms 2044 KB
in15.txt AC 8 ms 2172 KB
in16.txt AC 7 ms 1788 KB
in17.txt AC 10 ms 2044 KB
in18.txt AC 10 ms 2044 KB
in19.txt AC 20 ms 2684 KB
in2.txt AC 22 ms 2812 KB
in20.txt AC 9 ms 2172 KB
in3.txt AC 249 ms 9848 KB
in4.txt AC 192 ms 17452 KB
in5.txt AC 8 ms 2044 KB
in6.txt AC 7 ms 1916 KB
in7.txt AC 7 ms 2044 KB
in8.txt AC 22 ms 2812 KB
in9.txt AC 210 ms 18456 KB
long.txt AC 210 ms 58604 KB
long2.txt AC 218 ms 79152 KB
sample1.txt AC 7 ms 1788 KB
sample2.txt AC 7 ms 1788 KB
sample3.txt AC 7 ms 1788 KB