結果
問題 | No.3044 April Sum of Odd |
ユーザー | akakimidori |
提出日時 | 2019-04-01 21:14:12 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 14 ms / 2,000 ms |
コード長 | 621 bytes |
コンパイル時間 | 943 ms |
コンパイル使用メモリ | 28,980 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-08-17 13:36:18 |
合計ジャッジ時間 | 1,000 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,376 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,380 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 1 ms
4,376 KB |
testcase_08 | AC | 1 ms
4,376 KB |
testcase_09 | AC | 2 ms
4,380 KB |
testcase_10 | AC | 14 ms
4,376 KB |
testcase_11 | AC | 8 ms
4,376 KB |
testcase_12 | AC | 1 ms
4,376 KB |
ソースコード
#include<stdio.h> #include<stdlib.h> #include<stdint.h> #include<inttypes.h> typedef int32_t i32; typedef int64_t i64; void run (void) { i32 n, m; scanf ("%" SCNi32 "%" SCNi32, &n, &m); i32 *a = (i32 *) calloc (n, sizeof (i32)); for (i32 i = 0; i < n; ++i) { scanf ("%" SCNi32, a + i); } i32 l = 0; while (l < n) { if (a[l] % 2 == 0) { l++; continue; } i64 sum = a[l]; i32 r = l + 1; while (r < n && a[r] % 2 == 1) { sum += a[r++]; } if (r - l >= m) { printf ("%" PRIi64 "\n", sum); } l = r; } } int main (void) { run (); return 0; }