結果

問題 No.3044 April Sum of Odd
ユーザー konishikonishi
提出日時 2023-11-07 08:33:10
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 1,484 bytes
コンパイル時間 3,149 ms
コンパイル使用メモリ 249,188 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-11-07 08:33:15
合計ジャッジ時間 4,471 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
//#include<atcoder/all>
//using namespace atcoder;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define pii pair<int,int>
#define pll pair<ll,ll>

#define rep(i,num,n) for(int i=num;i<(int)(n);i++) //for_loop
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,num,n) for(int i=num-1;i>=(int)(n);i--) //reverse_for>
#define in(x,a,b) (a<=x && x<b)//範囲
#define reo return 0
#define all(v) v.begin(),v.end()

#define INFI 1010000000
#define INFL 4000000000000000000
//#define ten(x) ((int)1e##x)
//#define tenll(x) ((ll)1e##x)
#define PI 3.14159265358979
//#define mint modint1000000007
#define mint modint998244353

bool chmin(ll &a,ll b){if(a>b){a=b;return true;}return false;}
bool chmax(ll &a,ll b){if(a<b){a=b;return true;}return false;}
bool chmin(int &a,int b){if(a>b){a=b;return true;}return false;}
bool chmax(int &a,int b){if(a<b){a=b;return true;}return false;}

int dx[]={0,0,1,-1};int dy[]={1,-1,0,0};
//int dx[]={1,1,1,0,0,-1,-1,-1},dy[]={1,0,-1,1,-1,1,0,-1};
//----------------------------
int  main(){
    int n,m;cin>>n>>m;
    vector<ll>a(n);
    rep(i,0,n)cin>>a[i];
    vector<ll>ans;
    rep(i,0,n){
        if(a[i]%2==1){
            int cnt=0;
            ll sm=0;
            while(a[i]%2==1){
                sm+=a[i];
                i++;
                cnt++;
            }
            if(cnt>=m)ans.push_back(sm);
        }
    }
    for(auto a:ans)cout<<a<<endl;
}
0