/ 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 324.0 KiB
#4 Wrong Answer 1ms 320.0 KiB
#5 Accepted 1ms 484.0 KiB
#6 Accepted 1ms 320.0 KiB
#7 Wrong Answer 1ms 532.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
const int N = 1e7 + 9;
int a[N];

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    ll sum = -1e18;
    ll max_sum = -1e18;
    ll cnt = 0;
    for (int i = 0; i < n; i++)
    {
        sum = max(1LL * a[i], a[i] + sum);
        max_sum = max(max_sum, sum);
        if (max_sum % 2 == 0)
        {
            cnt++;
        }
    }

    if (cnt == 0)
    {
        cout << "-1\n";
    }
    else
    {
        cout << cnt << '\n';
    }

    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 17:44:20
Judged At
2024-11-11 03:37:28
Judged By
Score
30
Total Time
1ms
Peak Memory
532.0 KiB