結果
| 問題 | No.30 たこやき工場 |
| コンテスト | |
| ユーザー |
fal_rnd
|
| 提出日時 | 2016-11-27 10:40:11 |
| 言語 | Java (openjdk 25.0.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,109 bytes |
| 記録 | |
| コンパイル時間 | 2,102 ms |
| コンパイル使用メモリ | 78,492 KB |
| 実行使用メモリ | 700,024 KB |
| 最終ジャッジ日時 | 2024-11-27 12:08:18 |
| 合計ジャッジ時間 | 11,964 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 TLE * 1 |
ソースコード
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);
}
}
fal_rnd