/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 324.0 KiB
#2 Accepted 1ms 324.0 KiB
#3 Accepted 1ms 336.0 KiB
#4 Accepted 1ms 436.0 KiB
#5 Accepted 1ms 492.0 KiB
#6 Accepted 1ms 536.0 KiB
#7 Accepted 1ms 564.0 KiB
#8 Accepted 1ms 320.0 KiB
#9 Wrong Answer 33ms 928.0 KiB
#10 Accepted 33ms 924.0 KiB
#11 Wrong Answer 31ms 788.0 KiB

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