結果
問題 |
No.8044 April Sum of Odd
|
ユーザー |
|
提出日時 | 2023-11-07 18:20:51 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 998 bytes |
コンパイル時間 | 2,630 ms |
コンパイル使用メモリ | 75,080 KB |
実行使用メモリ | 59,416 KB |
最終ジャッジ日時 | 2024-09-25 23:25:04 |
合計ジャッジ時間 | 6,166 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 2 WA * 8 |
ソースコード
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<Integer> ansList = new ArrayList<>(); for (int i = 0 ; i < n ; i++){ int a = as[i]; if(a % 2 == 1){ int cnt = 1; int sum = a; if(i != n - 1){ while(i < n - 1 && as[i+1] % 2 == 1){ sum += as[i+1]; cnt++; i++; } } if(cnt >= m){ ansList.add(sum); } } } for (int i : ansList){ System.out.println(i); } } }