結果
| 問題 | No.8044 April Sum of Odd |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-11-07 18:25:09 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 323 ms / 2,000 ms |
| コード長 | 925 bytes |
| 記録 | |
| コンパイル時間 | 1,566 ms |
| コンパイル使用メモリ | 83,100 KB |
| 実行使用メモリ | 53,136 KB |
| 最終ジャッジ日時 | 2026-04-13 02:20:41 |
| 合計ジャッジ時間 | 4,316 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
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 m = sc.nextInt();
int[] as = new int[n];
for (int i = 0 ; i < n ; i++){
as[i] = sc.nextInt();
}
List<Long> ansList = new ArrayList<>();
for (int i = 0 ; i < n ; i++){
int a = as[i];
if(a % 2 == 1){
int cnt = 1;
long sum = a;
while(i < n - 1 && as[i+1] % 2 == 1){
sum += as[i+1];
cnt++;
i++;
}
if(cnt >= m){
ansList.add(sum);
}
}
}
for (long i : ansList){
System.out.println(i);
}
}
}