Wrong Answer
Code
#include <iostream>
using namespace std;
int max_even_subarray(int arr[], int n) {
int count = 0;
int odd_count = 0;
for (int i = 0; i < n; i++) {
if (arr[i] % 2 != 0) {
odd_count++;
if (odd_count == 2) {
count++;
odd_count = 0;
}
} else {
count++;
}
}
if (odd_count != 0)
return -1;
return count;
}
int main() {
int n;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
cout << max_even_subarray(arr, n) << 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:26:42
- Judged At
- 2024-11-11 03:37:09
- Judged By
- Score
- 50
- Total Time
- 33ms
- Peak Memory
- 928.0 KiB