結果
| 問題 |
No.1007 コイン集め
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-09 01:47:20 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,432 bytes |
| コンパイル時間 | 2,448 ms |
| コンパイル使用メモリ | 76,692 KB |
| 実行使用メモリ | 49,740 KB |
| 最終ジャッジ日時 | 2024-11-07 20:24:12 |
| 合計ジャッジ時間 | 11,217 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 2 |
| other | AC * 8 WA * 11 |
ソースコード
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[] A=new long[N];
long ans=0;
for(int i=0;i<N;i++){
A[i]=sc.nextLong();
}
if(A[K-1]==0L){
System.out.println(0);
}else if(A[K-1]==1L){
for(int i=0;i<K-1;i++){
if(A[i]<=1){
ans=A[i];
}else{
ans+=A[i];
}
}
long ANS=ans;
ans=0;
for(int i=K;i<N;i++){
if(A[i]<=1){
ans+=A[i];
break;
}else{
ans+=A[i];
}
}
if(ANS>ans){
System.out.println(ANS);
}else{
System.out.println(ans);
}
}else{
for(int i=0;i<N;i++){
boolean through=false;
if(A[i]<=1&&!through){
ans=A[i];
}else if(A[i]<=1&&through){
ans+=A[i];
System.out.println(ans);
return;
}else{
ans+=A[i];
}
}
System.out.println(ans);
}
}
}