Submission #3591372


Source Code Expand

line = gets
line.chomp!

/(\d+)\s+(\d+)/ =~ line

n = $1.to_i
y = $2.to_i

fin = false
i = 0
while i <= n and not fin
  m1 = y - 10000*i
  if m1 == 0 and i == n
    printf("%d 0 0",i)
    fin = true
    break
  elsif m1 < 0
    printf("-1 -1 -1")
    fin = true
    break
  else
    j = 0
    while j <= n-i and not fin
      m2 = m1 - 5000*j
      k = n -i -j
      if m2 == 0
        if k == 0
          printf("%d %d 0",i,j)
          fin = true
        end
        break
      elsif m2 < 0
        break
      end
      if 1000*k == m2 and k >= 0
        printf("%d %d %d",i,j,k)
        fin = true
        break
      end
      j += 1
    end
  end
  i += 1
end

if not fin
  printf("-1 -1 -1")
end

Submission Info

Submission Time
Task C - Otoshidama
User axikon
Language Ruby (2.3.3)
Score 300
Code Size 752 Byte
Status AC
Exec Time 286 ms
Memory 3836 KB

Compile Error

./Main.rb:25: warning: `-' after local variable or literal is interpreted as binary operator
./Main.rb:25: warning: even though it seems like unary operator
./Main.rb:25: warning: `-' after local variable or literal is interpreted as binary operator
./Main.rb:25: warning: even though it seems like unary operator

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 24
Set Name Test Cases
Sample a01, a02, a03, a04
All a01, a02, a03, a04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24
Case Name Status Exec Time Memory
a01 AC 8 ms 1916 KB
a02 AC 7 ms 1788 KB
a03 AC 7 ms 1788 KB
a04 AC 286 ms 1788 KB
b05 AC 7 ms 1788 KB
b06 AC 7 ms 1788 KB
b07 AC 7 ms 1788 KB
b08 AC 7 ms 1788 KB
b09 AC 273 ms 3836 KB
b10 AC 12 ms 1788 KB
b11 AC 273 ms 1788 KB
b12 AC 7 ms 1788 KB
b13 AC 7 ms 1788 KB
b14 AC 7 ms 1788 KB
b15 AC 246 ms 1788 KB
b16 AC 265 ms 1788 KB
b17 AC 271 ms 1788 KB
b18 AC 7 ms 1788 KB
b19 AC 8 ms 1788 KB
b20 AC 7 ms 1788 KB
b21 AC 13 ms 1788 KB
b22 AC 13 ms 1788 KB
b23 AC 262 ms 1788 KB
b24 AC 252 ms 3836 KB