結果

問題 No.1007 コイン集め
ユーザー Mishan5055
提出日時 2020-03-09 01:33:51
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 925 bytes
コンパイル時間 3,216 ms
コンパイル使用メモリ 73,600 KB
実行使用メモリ 60,140 KB
最終ジャッジ日時 2024-11-07 20:23:53
合計ジャッジ時間 10,386 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int K=sc.nextInt();
        
        long ans=0;
        
        for(int i=0;i<N;i++){
            long tmp=sc.nextLong();
            if(i<K-1){
                if(tmp<=1){
                    ans=tmp;
                }else{
                    ans+=tmp;
                }
            }else if(i==K-1){
                if(tmp==0){
                    System.out.println(0);
                    return;
                }else{
                    ans+=tmp;
                }
            }else{
                if(tmp<=1){
                    ans+=tmp;
                    System.out.println(ans);
                    return;
                }else{
                    ans+=tmp;
                }
            }
        }
        
        System.out.println(ans);
    }
}
0