結果
問題 |
No.1007 コイン集め
|
ユーザー |
|
提出日時 | 2020-03-09 01:31:45 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 922 bytes |
コンパイル時間 | 2,358 ms |
コンパイル使用メモリ | 74,128 KB |
実行使用メモリ | 48,232 KB |
最終ジャッジ日時 | 2024-11-07 20:23:36 |
合計ジャッジ時間 | 10,116 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 WA * 8 |
ソースコード
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(); int ans=0; for(int i=0;i<N;i++){ int tmp=sc.nextInt(); 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); } }