[JAVA][HDU 1234][开门人和关门人]
2014-11-26 09:39
435 查看
[java] view
plaincopyprint?
import java.io.BufferedInputStream;
import java.util.Date;
import java.util.Scanner;
import com.sun.org.apache.regexp.internal.recompile;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(new BufferedInputStream(System.in));
int days = sc.nextInt();// days of the records
for (int i = 0; i < days; i++) {
int details = sc.nextInt();
String id[] = new String[details];
String start[] = new String[details];
String end[] = new String[details];
String earliest = "23:59:59";
String lastest = "00:00:00";
String earliestMan = null;
String lastestMan = null;
for (int j = 0; j < details; j++) {
id[j] = sc.next();
start[j] = sc.next();
end[j] = sc.next();
if (start[j].compareTo(earliest) <= 0) {
// if the start-time of the worker are earlier than the recoreded-easiest-time
earliest = start[j];
earliestMan = id[j];
}
if (lastest.compareTo(end[j]) <= 0) {
// if the end-time of the worker are later
lastest = end[j];
lastestMan = id[j];
}
}
System.out.println(earliestMan + " " + lastestMan);
}
}
}
水题了不多说。。
plaincopyprint?
import java.io.BufferedInputStream;
import java.util.Date;
import java.util.Scanner;
import com.sun.org.apache.regexp.internal.recompile;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(new BufferedInputStream(System.in));
int days = sc.nextInt();// days of the records
for (int i = 0; i < days; i++) {
int details = sc.nextInt();
String id[] = new String[details];
String start[] = new String[details];
String end[] = new String[details];
String earliest = "23:59:59";
String lastest = "00:00:00";
String earliestMan = null;
String lastestMan = null;
for (int j = 0; j < details; j++) {
id[j] = sc.next();
start[j] = sc.next();
end[j] = sc.next();
if (start[j].compareTo(earliest) <= 0) {
// if the start-time of the worker are earlier than the recoreded-easiest-time
earliest = start[j];
earliestMan = id[j];
}
if (lastest.compareTo(end[j]) <= 0) {
// if the end-time of the worker are later
lastest = end[j];
lastestMan = id[j];
}
}
System.out.println(earliestMan + " " + lastestMan);
}
}
}
水题了不多说。。
相关文章推荐
- hdu1234开门人和关门人用二维数组
- HDU 1234 开门人和关门人
- hdu 1234开门人和关门人
- HDU 1234 开门人和关门人
- HDU 1234 - 开门人和关门人
- HDU 1234 开门人和关门人
- hdu 1234 开门人和关门人
- HDU 1234 开门人和关门人
- HDU 1234(开门人和关门人-scanf解决带注释数字读入)
- HDU 1234 开门人和关门人
- HDU 1234 开门人和关门人
- hdu 1234 开门人和关门人
- HDU 1234 开门人和关门人
- HDU--1234 -- 开门人和关门人
- HDU1234(开门人和关门人)
- HDU---开门人和关门人---1234
- Hdu 1234 开门人和关门人
- HDU1234-开门人和关门人
- hdu-1234开门人和关门人
- HDU 1234 开门人和关门人 (比较大小)