結果
問題 | No.409 ダイエット |
ユーザー | ciel |
提出日時 | 2016-04-19 00:04:05 |
言語 | Ruby (3.3.0) |
結果 |
AC
|
実行時間 | 562 ms / 2,000 ms |
コード長 | 1,061 bytes |
コンパイル時間 | 53 ms |
コンパイル使用メモリ | 7,552 KB |
実行使用メモリ | 34,816 KB |
最終ジャッジ日時 | 2024-06-26 09:29:57 |
合計ジャッジ時間 | 26,389 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 140 ms
17,536 KB |
testcase_01 | AC | 137 ms
17,664 KB |
testcase_02 | AC | 128 ms
17,664 KB |
testcase_03 | AC | 128 ms
17,792 KB |
testcase_04 | AC | 124 ms
17,792 KB |
testcase_05 | AC | 125 ms
17,920 KB |
testcase_06 | AC | 128 ms
17,664 KB |
testcase_07 | AC | 129 ms
17,408 KB |
testcase_08 | AC | 125 ms
17,792 KB |
testcase_09 | AC | 127 ms
17,792 KB |
testcase_10 | AC | 127 ms
17,920 KB |
testcase_11 | AC | 128 ms
17,664 KB |
testcase_12 | AC | 129 ms
17,920 KB |
testcase_13 | AC | 127 ms
17,792 KB |
testcase_14 | AC | 127 ms
17,792 KB |
testcase_15 | AC | 132 ms
17,792 KB |
testcase_16 | AC | 128 ms
17,920 KB |
testcase_17 | AC | 132 ms
17,664 KB |
testcase_18 | AC | 131 ms
17,664 KB |
testcase_19 | AC | 126 ms
17,792 KB |
testcase_20 | AC | 129 ms
17,792 KB |
testcase_21 | AC | 131 ms
17,536 KB |
testcase_22 | AC | 131 ms
17,792 KB |
testcase_23 | AC | 129 ms
17,792 KB |
testcase_24 | AC | 126 ms
17,792 KB |
testcase_25 | AC | 127 ms
17,792 KB |
testcase_26 | AC | 127 ms
17,792 KB |
testcase_27 | AC | 128 ms
17,536 KB |
testcase_28 | AC | 126 ms
17,664 KB |
testcase_29 | AC | 126 ms
17,920 KB |
testcase_30 | AC | 130 ms
17,536 KB |
testcase_31 | AC | 124 ms
17,792 KB |
testcase_32 | AC | 125 ms
17,792 KB |
testcase_33 | AC | 124 ms
17,664 KB |
testcase_34 | AC | 129 ms
17,664 KB |
testcase_35 | AC | 135 ms
17,280 KB |
testcase_36 | AC | 132 ms
17,408 KB |
testcase_37 | AC | 132 ms
17,536 KB |
testcase_38 | AC | 131 ms
17,408 KB |
testcase_39 | AC | 131 ms
17,792 KB |
testcase_40 | AC | 132 ms
17,408 KB |
testcase_41 | AC | 134 ms
17,408 KB |
testcase_42 | AC | 130 ms
17,408 KB |
testcase_43 | AC | 133 ms
17,408 KB |
testcase_44 | AC | 135 ms
17,664 KB |
testcase_45 | AC | 131 ms
17,408 KB |
testcase_46 | AC | 134 ms
17,408 KB |
testcase_47 | AC | 132 ms
17,408 KB |
testcase_48 | AC | 133 ms
17,792 KB |
testcase_49 | AC | 131 ms
17,408 KB |
testcase_50 | AC | 135 ms
17,408 KB |
testcase_51 | AC | 132 ms
17,280 KB |
testcase_52 | AC | 129 ms
17,536 KB |
testcase_53 | AC | 132 ms
17,408 KB |
testcase_54 | AC | 136 ms
17,664 KB |
testcase_55 | AC | 341 ms
29,952 KB |
testcase_56 | AC | 527 ms
31,068 KB |
testcase_57 | AC | 548 ms
32,784 KB |
testcase_58 | AC | 308 ms
28,544 KB |
testcase_59 | AC | 392 ms
30,336 KB |
testcase_60 | AC | 294 ms
29,312 KB |
testcase_61 | AC | 482 ms
30,608 KB |
testcase_62 | AC | 508 ms
32,388 KB |
testcase_63 | AC | 508 ms
31,564 KB |
testcase_64 | AC | 325 ms
29,824 KB |
testcase_65 | AC | 535 ms
32,044 KB |
testcase_66 | AC | 541 ms
31,104 KB |
testcase_67 | AC | 452 ms
32,124 KB |
testcase_68 | AC | 402 ms
30,976 KB |
testcase_69 | AC | 506 ms
31,780 KB |
testcase_70 | AC | 486 ms
33,408 KB |
testcase_71 | AC | 325 ms
30,208 KB |
testcase_72 | AC | 562 ms
34,816 KB |
testcase_73 | AC | 535 ms
34,304 KB |
testcase_74 | AC | 367 ms
31,360 KB |
testcase_75 | AC | 524 ms
34,176 KB |
testcase_76 | AC | 392 ms
32,384 KB |
testcase_77 | AC | 327 ms
29,952 KB |
testcase_78 | AC | 328 ms
30,848 KB |
testcase_79 | AC | 298 ms
28,800 KB |
testcase_80 | AC | 515 ms
33,280 KB |
testcase_81 | AC | 537 ms
33,024 KB |
testcase_82 | AC | 424 ms
31,180 KB |
testcase_83 | AC | 451 ms
32,608 KB |
testcase_84 | AC | 400 ms
31,488 KB |
testcase_85 | AC | 157 ms
18,432 KB |
testcase_86 | AC | 397 ms
31,232 KB |
testcase_87 | AC | 482 ms
33,536 KB |
testcase_88 | AC | 269 ms
27,904 KB |
testcase_89 | AC | 449 ms
32,512 KB |
testcase_90 | AC | 266 ms
27,264 KB |
testcase_91 | AC | 470 ms
31,744 KB |
コンパイルメッセージ
Main.rb:26: warning: mismatched indentations at 'end' with 'while' at 24 Main.rb:29: warning: mismatched indentations at 'end' with 'def' at 22 Main.rb:33: warning: mismatched indentations at 'end' with 'while' at 31 Main.rb:52: warning: `-' after local variable or literal is interpreted as binary operator Main.rb:52: warning: even though it seems like unary operator Syntax OK
ソースコード
#!/usr/bin/ruby def is_minimam(a1,b1,a2,b2,a3,b3) (a2-a1)*(b3-b2)>=(b2-b1)*(a3-a2) end def is_maximam(a1,b1,a2,b2,a3,b3) is_minimam(-a1,-b1,-a2,-b2,-a3,-b3) end def check(l1,l2,l3) is_minimam(l1[0],l1[1],l2[0],l2[1],l3[0],l3[1]) end def calc(l,now) l[0]*now+l[1] end class ConvexHullTrick def initialize @deque=100000.times.map{[0,0]} @s=0 @t=0 end def add(a,b) l=[a,b] while @s+1<@t&&check(@deque[@t-2],@deque[@t-1],l) @t-=1 end @deque[@t]=l @t+=1 end def get(now) while @s+1<@t&&calc(@deque[@s],now)>=calc(@deque[@s+1],now) @s+=1 end calc(@deque[@s],now) end end n,a,b,w=gets.split.map(&:to_i) d=gets.split.map(&:to_i) deq=ConvexHullTrick.new dp=[Float::INFINITY]*(n+1) dp[0]=w deq.add( - 0 * b,dp[0] + 0 * a + b * 0 * (0 - 1) / 2) n.times{|i| dp[i + 1] = d[i] - i * a + ( b * i * (i + 1)) / 2 + deq.get(i) deq.add( - (i + 1) * b , dp[i + 1] + (i + 1) * a + ( b * (i + 1) * i) / 2) } res=Float::INFINITY (n+1).times{|i| res=[res,dp[i] - a * (n -i) + b * (n - i) * (n - i + 1) / 2].min } p res