题目1022:游船出租
来源:互联网 发布:c语言分配内存 编辑:程序博客网 时间:2024/04/28 18:35
import java.util.ArrayList;import java.util.List;import java.util.Scanner;public class Main {private static class Boat{int Stime=9999;int Etime=9999;int No;public Boat(int No,int Stime,int Etime ) {this.setEtime(Etime);this.setStime(Stime);this.setNo(No);}public void setStime(int S_time){this.Stime = S_time;}public void setEtime(int E_time){this.Etime = E_time;}public void setNo(int No){this.No = No;}public int getStime(){return this.Stime;}public int getEime(){return this.Etime;}public int getNo(){return this.No;}public int gettime(){return this.Etime-this.Stime;}}public static void main(String arg[]){Scanner sc = new Scanner(System.in);while(sc.hasNext()){List<Boat> boats = new ArrayList<Boat>();String temp = sc.nextLine();if(temp.equals("-1")) break;while(true){//分割字符串String[] str = temp.split(" ");Integer No = Integer.parseInt(str[0]);if(No==0) break;//转化成分钟计的时间函数String[] temp1 = str[2].split(":");Integer time = Integer.parseInt(temp1[0])*60+Integer.parseInt(temp1[1]); Integer flag=0;//是否已经在列表中for(Boat i:boats){if(i.getNo()==No) {flag=1;if(str[1].equals("S")) i.setStime(time);if(str[1].equals("E")) i.setEtime(time);break;}}//不在列表中if(flag==0) {if(str[1].equals("S")) boats.add(new Boat(No, time, 9999));if(str[1].equals("E")) boats.add(new Boat(No, 9999, time));}temp = sc.nextLine();}//输出Integer totaltime=0;Integer count=0;for(Boat i : boats){if(i.getEime()==9999 || i.getStime()==9999) continue;totaltime += i.gettime();count++;}System.out.println(count==0?count+" "+0:count+" "+(Integer)Math.round((float)totaltime/(float)count));boats.clear();}}}
0 0
- 题目1022:游船出租
- 题目1022:游船出租
- 题目1022:游船出租
- 题目1022:游船出租
- 题目1022:游船出租
- 题目1022:游船出租
- 题目1022:游船出租
- 题目1022:游船出租
- 题目1022:游船出租
- 题目1022:游船出租
- 题目1022:游船出租
- 九度OJ 题目1022:游船出租
- 九度oj 题目1022:游船出租
- 九度OJ 题目1022:游船出租
- 九度 Online Judge 算法 刷题 题目1022:游船出租
- 九度 1022 游船出租
- 九度:1022:游船出租
- HDOJ 题目1861 游船出租(水题)
- HyperX Savage系列 DDR3 2400 16GB (8GBx2)玩虚拟化部署
- 第十二周项目3.2求1*3*……*n的递归式
- N个富文本编辑器/基于Web的HTML编辑器
- 复制(克隆)一:dos功能---文件、分区复制(与ghost克隆功能一样)推荐首用
- Windows Console 控制台、窗口界面切换
- 题目1022:游船出租
- 开源.NET编译平台Roslyn,微软正在拉近与开发者的距离
- 第十二周项目1-阅读程序(五)
- java学习笔记(六)关键字static的使用
- oracle中nvl()函数
- ShareSDK for iOS V 2.10.1和ShareSDK for Android V 2.5.1 版本齐发布
- Oracle本地命名服务tnsnames.ora配置
- 第十二周 项目一 2-1
- float原理与使用详解