結果

問題 No.138 化石のバージョン
ユーザー tsunabittsunabit
提出日時 2018-05-06 13:43:02
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,811 bytes
コンパイル時間 3,950 ms
コンパイル使用メモリ 77,708 KB
実行使用メモリ 57,832 KB
最終ジャッジ日時 2023-09-10 10:44:41
合計ジャッジ時間 10,950 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,872 KB
testcase_01 AC 132 ms
55,820 KB
testcase_02 AC 125 ms
56,204 KB
testcase_03 AC 124 ms
55,940 KB
testcase_04 AC 124 ms
55,780 KB
testcase_05 AC 125 ms
56,452 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 122 ms
55,816 KB
testcase_17 AC 121 ms
55,580 KB
testcase_18 AC 125 ms
55,868 KB
testcase_19 AC 126 ms
55,612 KB
testcase_20 AC 125 ms
55,892 KB
testcase_21 AC 124 ms
55,912 KB
testcase_22 AC 125 ms
55,924 KB
testcase_23 AC 124 ms
55,824 KB
testcase_24 AC 125 ms
56,272 KB
testcase_25 AC 123 ms
55,948 KB
testcase_26 WA -
testcase_27 AC 125 ms
55,736 KB
testcase_28 AC 123 ms
55,960 KB
testcase_29 AC 124 ms
55,952 KB
testcase_30 AC 124 ms
56,120 KB
testcase_31 AC 125 ms
55,944 KB
testcase_32 AC 124 ms
55,872 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
権限があれば一括ダウンロードができます

ソースコード

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で読み込む
        // String f = sc.next();
        // String s = sc.next();
        // int n = Integer.parseInt(sc.nextLine());
        // 新しいstreamを作成し、各要素をintに変換
        // int[] x = Stream.of(sc.nextLine().split(" " , 0)).mapToInt(Integer::parseInt).toArray();
        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";
            }
        }
        System.out.println(kaseki);

        // ------------------------------------------------------------
        // System.out.println("n = " + f);
        // 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