結果

問題 No.652 E869120 and TimeZone
ユーザー uafr_csuafr_cs
提出日時 2018-02-23 22:36:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 121 ms / 1,000 ms
コード長 2,658 bytes
コンパイル時間 2,818 ms
コンパイル使用メモリ 74,388 KB
実行使用メモリ 56,260 KB
最終ジャッジ日時 2023-09-02 05:21:22
合計ジャッジ時間 8,092 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
55,772 KB
testcase_01 AC 118 ms
55,728 KB
testcase_02 AC 121 ms
55,552 KB
testcase_03 AC 121 ms
55,320 KB
testcase_04 AC 114 ms
55,368 KB
testcase_05 AC 114 ms
56,260 KB
testcase_06 AC 113 ms
55,296 KB
testcase_07 AC 115 ms
55,168 KB
testcase_08 AC 113 ms
55,664 KB
testcase_09 AC 112 ms
55,860 KB
testcase_10 AC 114 ms
55,696 KB
testcase_11 AC 117 ms
55,364 KB
testcase_12 AC 114 ms
55,660 KB
testcase_13 AC 115 ms
55,648 KB
testcase_14 AC 113 ms
55,412 KB
testcase_15 AC 114 ms
55,300 KB
testcase_16 AC 114 ms
55,660 KB
testcase_17 AC 115 ms
55,652 KB
testcase_18 AC 112 ms
55,812 KB
testcase_19 AC 111 ms
55,932 KB
testcase_20 AC 111 ms
55,584 KB
testcase_21 AC 110 ms
55,812 KB
testcase_22 AC 109 ms
53,472 KB
testcase_23 AC 110 ms
55,504 KB
testcase_24 AC 110 ms
55,572 KB
testcase_25 AC 111 ms
55,440 KB
testcase_26 AC 111 ms
55,456 KB
testcase_27 AC 111 ms
55,496 KB
testcase_28 AC 111 ms
55,564 KB
testcase_29 AC 113 ms
55,676 KB
testcase_30 AC 120 ms
55,284 KB
testcase_31 AC 121 ms
55,424 KB
testcase_32 AC 119 ms
55,308 KB
testcase_33 AC 111 ms
56,140 KB
testcase_34 AC 112 ms
55,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.StringTokenizer;
 
public class Main {
	
	public static final long INF = Long.MAX_VALUE / 2 -1;
	
	public static void main(String[] args) throws IOException {
		try (Scanner sc = new Scanner(System.in)) {
			final int h = sc.nextInt();
			final int m = sc.nextInt();
			
			int minutes = h * 60 + m;
			String str = sc.next().substring(3);
			
			if(str.charAt(0) == '-'){
				str = str.substring(1);
				
				if(str.indexOf(".") < 0){
					minutes -= 60 * (Integer.parseInt(str) + 9);
				}else{
					minutes -= 60 * (Integer.parseInt(str.substring(0, str.indexOf("."))) + 9);

					final String lower = str.substring(str.indexOf(".") + 1);
					minutes -= 6 * Integer.parseInt(lower);
				}
				
					while(minutes < 0){ minutes += 60 * 24; }
			}else{
				if(str.indexOf(".") < 0){
					minutes += 60 * (Integer.parseInt(str) - 9);
				}else{
					minutes += 60 * (Integer.parseInt(str.substring(0, str.indexOf("."))) - 9);
					
					final String lower = str.substring(str.indexOf(".") + 1);
					minutes += 6 * Integer.parseInt(lower);
				}
				
				while(minutes < 0){ minutes += 60 * 24; }
			}
			
			System.out.printf("%02d:%02d\n", (minutes / 60) % 24, minutes % 60);
			
		}
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextInt();
			}
			return ret;
		}
 
		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = this.nextLong();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}
0