您的位置:首页 > 编程语言 > Java开发

[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);

}

}

}

水题了不多说。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: