/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 524.0 KiB
#3 Accepted 1ms 468.0 KiB
#4 Accepted 1ms 532.0 KiB
#5 Accepted 1ms 320.0 KiB
#6 Accepted 1ms 532.0 KiB
#7 Accepted 1ms 532.0 KiB
#8 Accepted 1ms 384.0 KiB
#9 Wrong Answer 29ms 924.0 KiB
#10 Accepted 29ms 920.0 KiB
#11 Wrong Answer 29ms 928.0 KiB
#12 Wrong Answer 1ms 532.0 KiB
#13 Wrong Answer 1ms 532.0 KiB
#14 Accepted 16ms 924.0 KiB
#15 Wrong Answer 16ms 928.0 KiB
#16 Wrong Answer 16ms 832.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-10-03 13:55:08
Judged By
Score
55
Total Time
29ms
Peak Memory
928.0 KiB