結果

問題 No.2559 眩しい数直線
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2024-02-02 05:11:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 230 ms / 2,000 ms
コード長 1,112 bytes
コンパイル時間 2,347 ms
コンパイル使用メモリ 79,624 KB
実行使用メモリ 58,684 KB
最終ジャッジ日時 2024-02-02 05:11:58
合計ジャッジ時間 8,135 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
58,084 KB
testcase_01 AC 130 ms
57,940 KB
testcase_02 AC 131 ms
58,068 KB
testcase_03 AC 174 ms
56,144 KB
testcase_04 AC 166 ms
57,960 KB
testcase_05 AC 224 ms
56,432 KB
testcase_06 AC 223 ms
58,492 KB
testcase_07 AC 217 ms
58,604 KB
testcase_08 AC 208 ms
58,356 KB
testcase_09 AC 206 ms
58,564 KB
testcase_10 AC 195 ms
58,504 KB
testcase_11 AC 159 ms
57,972 KB
testcase_12 AC 153 ms
58,180 KB
testcase_13 AC 224 ms
58,480 KB
testcase_14 AC 219 ms
58,580 KB
testcase_15 AC 226 ms
58,408 KB
testcase_16 AC 163 ms
58,096 KB
testcase_17 AC 228 ms
58,660 KB
testcase_18 AC 178 ms
57,952 KB
testcase_19 AC 222 ms
58,416 KB
testcase_20 AC 206 ms
58,684 KB
testcase_21 AC 160 ms
58,192 KB
testcase_22 AC 230 ms
58,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
import java.util.*;

public class Main {

    public static void vectorPrint(Vector lis){

        PrintWriter out = new PrintWriter(System.out);
        for (int i=0 ; i<lis.size() ; i++){
            out.print(lis.get(i));
            if ( i != lis.size()-1){
                out.print(' ');
            }else{
                out.print('\n');
            }
        }
        out.flush();
    }

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int N = Integer.parseInt(sc.next());
        int X = Integer.parseInt(sc.next());
        int[] A = new int[N];
        int[] B = new int[N];
        Vector anslis = new Vector();

        for (int i=0; i<N ; i++){
            A[i] = Integer.parseInt(sc.next());
            B[i] = Integer.parseInt(sc.next());
        }

        for (int j=1; j<=X ; j++){
            int ans = 0;
            for (int i=0; i<N ; i++){
                ans = Math.max(ans , B[i]-Math.abs(j-A[i]));
            }
            anslis.addElement(ans);
        }

        vectorPrint(anslis);
        
    }
}
0