結果

問題 No.3044 April Sum of Odd
ユーザー トミートミー
提出日時 2024-01-04 00:46:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 482 bytes
コンパイル時間 2,078 ms
コンパイル使用メモリ 200,752 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-04 00:46:09
合計ジャッジ時間 3,334 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#define REPP(i,n,m) for(int i=n;i<=m;i++)
#define REPM(i,n,m) for(int i=n;i>=m;i--)
using namespace std;
void yn(bool f){if(f){cout<<"Yes\n";}else{cout<<"No\n";}}
bool isnum(char c){return ('0'<=c&&c<='9');}

int main(){
	int64_t n,m;
	int64_t a=0,sum=0,cnt=0;
	cin>>n>>m;
	REPP(i,0,n-1){
		cin>>a;
		if(a%2==1){
			sum+=a;
			cnt++;
		}
		else{
			if(cnt>=m){
				cout<<sum<<"\n";
			}
			sum=0;
			cnt=0;
		}
	}
	if(cnt>=m){
		cout<<sum<<"\n";
	}
	
	
	
	
}
0