結果

問題 No.3044 April Sum of Odd
ユーザー RadperiaRadperia
提出日時 2019-04-01 21:47:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,528 bytes
コンパイル時間 1,492 ms
コンパイル使用メモリ 167,284 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-17 21:40:15
合計ジャッジ時間 2,319 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define INF 1145141919
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int ny, nx;
typedef long long int ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

int ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
////////////////////////////////////////////////////////////////////
int main()
{
    int N,M; cin >> N >> M;
    vector<ll> a(N);
    REP(i,N) cin >> a[i];

    /*vector<ll> s(N+1,0);
    REP(i,N) s[i+1] = s[i] + a[i];

    REP(i,N) cout << s[i] << endl;*/
    ll ans=0;
    bool flag=false;
    ll cnt=0;
    ll hold=0;
    REP(i,N){
        if(a[i]%2!=0){
            flag=true;
            cnt++;
            hold+=a[i];
        }else if(a[i]%2==0 or i==(N-1)){
            if(a[i]%2==0) flag=false;
            if(hold!=0) cout << hold << endl;
            if (i != (N - 1))
            {
                cnt = 0;
                hold = 0;
            }
            ans=0;
        }
        //cout << "flag= " << flag << " cnt= " << cnt << " hold= " << hold << endl;

        if(i==(N-1) and a[i]%2!=0) cout << hold << endl;
    }

    return 0;
}
0