結果

問題 No.3044 April Sum of Odd
ユーザー NishionyamaNishionyama
提出日時 2019-04-01 23:29:13
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 1,215 bytes
コンパイル時間 1,480 ms
コンパイル使用メモリ 165,752 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 02:42:58
合計ジャッジ時間 2,213 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 15 ms
4,376 KB
testcase_11 AC 9 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N,M;

    Scd2(N,M);

    vector<ll> a(N,0);

    Rep(i,N){
        Scll(a[i]);
    }

    ll tmp = 0;
    int cnt = 0;
    Rep(i,N){
        if( a[i] % 2 ){
            tmp += a[i];
            cnt++;
        }else{
            if( tmp && cnt >= M )
            printf ("%llu\n", tmp);
            tmp = 0;
            cnt = 0;
        }
    }
    if( tmp && cnt >= M )
    printf ("%llu\n", tmp);

    return 0;
}

0