結果
問題 |
No.8044 April Sum of Odd
|
ユーザー |
|
提出日時 | 2023-11-07 18:18:49 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 996 bytes |
コンパイル時間 | 1,896 ms |
コンパイル使用メモリ | 75,800 KB |
実行使用メモリ | 61,108 KB |
最終ジャッジ日時 | 2024-09-25 23:24:56 |
合計ジャッジ時間 | 5,702 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
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(cnt < m && 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); } } }