結果

問題 No.1006 Share an Integer
ユーザー shi-moshi-mo
提出日時 2020-09-30 21:49:51
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 302 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 11,556 KB
実行使用メモリ 73,996 KB
最終ジャッジ日時 2023-09-20 17:30:41
合計ジャッジ時間 8,013 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,152 KB
testcase_01 AC 78 ms
14,940 KB
testcase_02 AC 79 ms
15,232 KB
testcase_03 AC 79 ms
15,068 KB
testcase_04 AC 79 ms
15,056 KB
testcase_05 AC 80 ms
15,168 KB
testcase_06 AC 80 ms
15,024 KB
testcase_07 AC 81 ms
15,112 KB
testcase_08 AC 81 ms
15,052 KB
testcase_09 AC 82 ms
15,240 KB
testcase_10 AC 80 ms
15,112 KB
testcase_11 TLE -
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

x = gets.to_i

f = (0..x).map{|i| i-1 }
2.upto(x) do |i|
  i.step(x, i){|j| f[j] -= 1 }
end

p = [] * (x/2).ceil
1.upto(x/2) do |a|
  b = x - a
  score = (f[a]-f[b]).abs
  p[score] ||= []
  p[score] << a
  p[score] << b if b != a
end

ans = p.find{|pi| !pi.nil? }
ans.sort.each{|a| puts "#{a} #{x-a}" }
0