結果

問題 No.138 化石のバージョン
ユーザー tsunabittsunabit
提出日時 2018-05-06 15:04:06
言語 Java21
(openjdk 21)
結果
AC  
実行時間 129 ms / 5,000 ms
コード長 2,998 bytes
コンパイル時間 3,886 ms
コンパイル使用メモリ 77,172 KB
実行使用メモリ 56,296 KB
最終ジャッジ日時 2023-09-10 10:45:22
合計ジャッジ時間 9,746 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
56,048 KB
testcase_01 AC 126 ms
56,096 KB
testcase_02 AC 126 ms
56,080 KB
testcase_03 AC 127 ms
55,868 KB
testcase_04 AC 129 ms
56,168 KB
testcase_05 AC 126 ms
55,460 KB
testcase_06 AC 127 ms
55,468 KB
testcase_07 AC 127 ms
56,028 KB
testcase_08 AC 125 ms
56,296 KB
testcase_09 AC 129 ms
55,900 KB
testcase_10 AC 128 ms
55,672 KB
testcase_11 AC 128 ms
55,820 KB
testcase_12 AC 124 ms
56,072 KB
testcase_13 AC 126 ms
55,744 KB
testcase_14 AC 125 ms
55,556 KB
testcase_15 AC 127 ms
55,740 KB
testcase_16 AC 128 ms
55,756 KB
testcase_17 AC 126 ms
55,936 KB
testcase_18 AC 127 ms
55,444 KB
testcase_19 AC 128 ms
55,732 KB
testcase_20 AC 128 ms
55,624 KB
testcase_21 AC 128 ms
56,132 KB
testcase_22 AC 126 ms
56,032 KB
testcase_23 AC 127 ms
55,808 KB
testcase_24 AC 125 ms
55,772 KB
testcase_25 AC 127 ms
56,076 KB
testcase_26 AC 126 ms
55,964 KB
testcase_27 AC 126 ms
55,732 KB
testcase_28 AC 127 ms
55,632 KB
testcase_29 AC 127 ms
55,808 KB
testcase_30 AC 123 ms
55,412 KB
testcase_31 AC 126 ms
55,840 KB
testcase_32 AC 127 ms
55,976 KB
testcase_33 AC 125 ms
55,992 KB
testcase_34 AC 129 ms
55,888 KB
testcase_35 AC 126 ms
55,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.stream.Stream;
import java.util.Arrays;

// ***問題文***
// 世の中的にはgcc 4.8.1が化石と言われているらしいです。
// ここで、化石と言われてるバージョンが特定の文字列の形式A.B.C (A,B,Cはそれぞれ0以上100以下の整数である)で
// 与えられるので、同じ形式で与えられたバージョンが化石かどうか判定してください。
// 化石のバージョンの場合は「YES」、化石のバージョンではない場合「NO」を出力してください
// 化石のバージョンとは、指定したバージョンと同じか、もしくはそれより古いものとする。
// 古いバージョンとは、「.」で区切られたものの、より左に書かれた数値が小さいかどうかとする。
// 例えば、4.8.1より 4.7.9のほうが古く、4.8.1より 4.9.0や5.0.1のほうが新しいとする。
// ***入力***
// A0.B0.C0
// A1.B1.C1
// 入力は全て整数で与えられ、.
// 区切りなことに注意
// 1行目は、化石だと言われるバージョンを示します。
// 2行目は、判定したいバージョンを示します。
// 0≤i≤1
// 0≤Ai≤100
// 0≤Bi≤100
// 0≤Ci≤100
// ***出力***
// 化石のバージョンの場合は「YES」、化石のバージョンではない場合「NO」を出力してください。
// 最後に改行をしてください。

public class No138 {
    public static void main(String[] args) {
        // 標準入力から読み込む際に、Scannerオブジェクトを使う。
        Scanner sc = new Scanner(System.in);
        // 2行目をnextLineで読み込むため、数値もnextLineで読み込む
        // int n = Integer.parseInt(sc.nextLine());
        // 新しいstreamを作成し、各要素をintに変換
        // int[] x = Stream.of(sc.nextLine().split(" " , 0)).mapToInt(Integer::parseInt).toArray();
        // int f = Integer.parseInt(sc.next().replace(".", ""));
        // int s = Integer.parseInt(sc.next().replace(".", ""));
        int[] f = Stream.of(sc.nextLine().split("\\." , 0)).mapToInt(Integer::parseInt).toArray();
        int[] s = Stream.of(sc.nextLine().split("\\." , 0)).mapToInt(Integer::parseInt).toArray();
        String kaseki = "YES";
        for(int i = 0; i < f.length; i++) {
            if(s[i] > f[i]) {
                kaseki = "NO";
                break;
            }else if(s[i] < f[i]) {
                break;
            }
        }
        System.out.println(kaseki);
        // ------------------------------------------------------------
        // System.out.println("n = " + f);
        // System.out.println("n = " + s);
        // System.out.println("n = " + fa.length);
        // for(int i = 0; i < f.length; i++) {
        //     System.out.println("[" + i + "] = " + f[i]);
        // }
        // for(int a: x) {
        //     System.out.println("x = " + x);
        // }
    }
}
0