Accepted
Code
/*
CODED BY mamudulsakib2019
DATE:-24/03/2024 ; TIME- 17:47 PM
BANGLADESH , SYLHET
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
int main() {
ll size;
cin >> size;
vector<ll> numbers(size);
for(ll i = 0; i < size; i++){
cin >> numbers[i];
}
ll evenSumSubarrays = 0, sum = 0;
for(ll num : numbers){
sum += num;
if(sum % 2 == 0){
evenSumSubarrays++;
sum = 0;
}
}
if(sum == 0){
cout << evenSumSubarrays << endl;
}
else{
cout << -1 << endl;
}
return 0;
}
Information
- Submit By
- Type
- Submission
- Problem
- P1042 Array partition
- Contest
- TLE_Headquarters - round #1
- Language
- C++20 (G++ 13.2.0)
- Submit At
- 2024-03-27 18:06:18
- Judged At
- 2024-11-11 03:37:19
- Judged By
- Score
- 100
- Total Time
- 32ms
- Peak Memory
- 1.293 MiB