当前位置:网站首页>Family Trivia
Family Trivia
2022-07-27 10:37:00 【chengqiuming】
One Link to original question
Chores - POJ 1949 - Virtual Judgehttps://vjudge.net/problem/POJ-1949
Two Input and output
1 Input
The first 1 Line contains an integer N. The first 2 ~ N+1 Line describes each household chore , The first 2 Line contains housework 1; The first 3 Line contains housework 2, And so on . Each line contains the time to complete the housework 、 Number of prerequisites Pi and Pi A prerequisite .
2 Output
Single line output the minimum time required to complete all housework .
3、 ... and Input and output samples
1 Input
7
5 0
1 1 1
3 1 2
6 1 1
1 2 2 4
8 2 2 4
4 3 3 5 6
2 Output
23
Four Analysis and design
1 Topology

2 analysis
The housework 1 In time 0 Start , In time 5 end ;
The housework 2 In time 0 Start , In time 6 end ;
The housework 3 In time 0 Start , In time 9 end ;
The housework 4 In time 0 Start , In time 11 end ;
The housework 5 In time 0 Start , In time 12 end ;
The housework 6 In time 0 Start , In time 19 end ;
The housework 7 In time 0 Start , In time 23 end ;
The key to this problem lies in , The housework k Only housework 1~k-1 As a prerequisite . in other words , Enter the first K When doing housework , Its prerequisites have determined when it will end . Therefore, in the input process, you can directly find the longest distance . If there are no preconditions , Then it can't be calculated in this way .
5、 ... and Code
package graph.poj1949;
import java.util.Scanner;
public class POJ1949 {
static final int maxn = 10010;
static int d[] = new int[maxn];
static int n;
public static void main(String[] args) {
int ans = 0, w, num, y;
Scanner scanner = new Scanner(System.in);
n = scanner.nextInt();
for (int i = 1; i <= n; i++) {
w = scanner.nextInt();
num = scanner.nextInt();
d[i] = w;
for (int j = 1; j <= num; j++) {
y = scanner.nextInt();
d[i] = Math.max(d[i], d[y] + w);
}
ans = Math.max(ans, d[i]);
}
System.out.println(ans);
}
}6、 ... and test
Green is the input , White is the output

边栏推荐
- 【精选】如何完美的写 PHP 代码的呢?
- [brother hero June training] day 28: dynamic planning
- 关于ETL的两种架构(ETL架构和ELT架构)
- Matlab/Simulink求解微分方程样例分享
- 01_ Movie recommendation (contentbased)_ Object portrait
- Matlab sound classification based on short-time neural network
- 游戏玩家问题
- PHP generates text and image watermarks
- Multipoint bidirectional republication and routing strategy
- Sorting out some open source projects of speech recognition
猜你喜欢

Establishment of NFS server

PHP generates text and image watermarks

Matlab low-level source code realizes the median filtering of the image (used to eliminate some miscellaneous points on the image)

邮件服务器

Ant advanced task

文件上传漏洞绕过方法

Local connection to remote server database under Windows platform (I)

多点双向重发布和路由策略

Mysql database experiment training 5, data query YGGL database query (detailed)

北京公示儿童鞋抽查 8组批产品不合格琪尔特登榜
随机推荐
FTP server
语音数据采集-实时语音数据可视化
Program translation and execution, from editing, preprocessing, compilation, assembly, linking to execution
厉害了!VMware ESXi安装记录,附下载
【Liunx】MariaDB/MySQL定时全量备份脚本及数据恢复
Introduction to Matlab real time editor
Different binary conversion of MATLAB
How to smooth the online and offline of Web Services
JVM -- Analysis of bytecode
Metasploit-永恒之蓝攻击
Girl fan wants to find a boyfriend, but it's for
Matlab create text cloud
Warning: remote head references to nonexistent ref, unable to checkout error messages
Ubuntu and MySQL quick start tutorial
家庭琐事问题
It is thought-provoking: is syntax really important? Qiu Xipeng group proposed a powerful baseline for aspect based emotional analysis
Metaaploit post penetration technology knowledge
FSM onehot answer record
Loop traversal of foreach and some of ES6
Ubuntu及Mysql快速入门教程