結果
問題 | No.30 たこやき工場 |
ユーザー | fal_rnd |
提出日時 | 2016-11-27 10:40:11 |
言語 | Java21 (openjdk 21) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,109 bytes |
コンパイル時間 | 2,186 ms |
コンパイル使用メモリ | 78,896 KB |
実行使用メモリ | 701,508 KB |
最終ジャッジ日時 | 2024-05-05 14:11:21 |
合計ジャッジ時間 | 11,549 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 101 ms
40,308 KB |
testcase_01 | AC | 98 ms
39,772 KB |
testcase_02 | AC | 98 ms
40,000 KB |
testcase_03 | AC | 105 ms
40,160 KB |
testcase_04 | AC | 113 ms
40,172 KB |
testcase_05 | AC | 110 ms
40,948 KB |
testcase_06 | AC | 113 ms
41,396 KB |
testcase_07 | AC | 101 ms
40,164 KB |
testcase_08 | AC | 214 ms
45,784 KB |
testcase_09 | AC | 153 ms
41,492 KB |
testcase_10 | TLE | - |
testcase_11 | AC | 550 ms
41,620 KB |
testcase_12 | AC | 112 ms
41,472 KB |
testcase_13 | AC | 117 ms
41,680 KB |
testcase_14 | AC | 144 ms
41,420 KB |
testcase_15 | AC | 139 ms
41,536 KB |
testcase_16 | AC | 149 ms
42,020 KB |
ソースコード
import java.util.*; class B{ static Scanner s = new Scanner(System.in); public static void main(String[] args) { Product[] products = new Product[Integer.parseInt(s.next())]; for (int i=0;i<products.length;i++) { products[i]=new Product(); } for(int i=Integer.parseInt(s.next());i>0;i--) { new Step( products[Integer.parseInt(s.next())-1], Integer.parseInt(s.next()), products[Integer.parseInt(s.next())-1] ); } ArrayDeque<Product> queue = new ArrayDeque<>(); queue.add(products[products.length-1]); products[products.length-1].needed++; while(!queue.isEmpty()) { Product p = queue.poll(); if(p.making.isEmpty()) { continue; } for(Step s:p.making) { s.from.needed+=p.needed*s.x; queue.add(s.from); } p.needed=0; } for(int i=0;i<products.length-1;i++) { System.out.println(products[i].needed); } } } class Product{ long needed=0; ArrayList<Step> making = new ArrayList<>(); } class Step{ Product from,to; long x; Step(Product from, int x, Product to) { this.from=from; this.x=x; to.making.add(this); } }