結果
問題 |
No.8044 April Sum of Odd
|
ユーザー |
|
提出日時 | 2023-11-07 18:25:09 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 596 ms / 2,000 ms |
コード長 | 925 bytes |
コンパイル時間 | 2,562 ms |
コンパイル使用メモリ | 75,424 KB |
実行使用メモリ | 48,188 KB |
最終ジャッジ日時 | 2024-09-25 23:25:11 |
合計ジャッジ時間 | 6,306 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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); } } }