Wrong Answer
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 = 1; i <= n; i++)
{
cin >> a[i];
}
ll sum = 0;
ll cnt = 0;
for (int i = 1; i <= n; i++)
{
sum = max(1LL * a[i], a[i] + sum);
if (sum % 2 == 0)
{
cnt++;
sum = 0;
}
}
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 16:59:46
- Judged At
- 2024-11-11 03:37:52
- Judged By
- Score
- 30
- Total Time
- 2ms
- Peak Memory
- 592.0 KiB