結果

問題 No.994 ばらばらコイン
ユーザー kusagame12
提出日時 2023-11-11 19:23:04
言語 Java
(openjdk 23)
結果
AC  
実行時間 754 ms / 2,000 ms
コード長 642 bytes
コンパイル時間 3,022 ms
コンパイル使用メモリ 73,836 KB
実行使用メモリ 53,464 KB
最終ジャッジ日時 2024-09-26 02:51:07
合計ジャッジ時間 13,524 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int k = sc.nextInt();
        
        int[] us = new int[n-1];
        int[] vs = new int[n-1];
        for (int i = 0 , len = n - 1; i < len ; i++){
            us[i] = sc.nextInt();
            vs[i] = sc.nextInt();
        } 
        
        if(k > n){
            System.out.println(-1);
        }else if(k == 1){
            System.out.println(0);
        }else{
            System.out.println(k - 1);
        }
           
    }
}
0