Accepted
Code
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
ios::sync_with_stdio(false), cin.tie(nullptr);
int t (1); //cin >> t;
while (t--) {
int n, ans (0), s(0); cin >> n;
vector <int> a(n);
for (auto &x:a) {
cin >> x; s += x;
if (s % 2 == 0) {
ans ++;
s = 0;
}
}
cout << (!s ? ans : -1) << '\n';
}
}
Information
- Submit By
- Type
- Submission
- Problem
- P1042 Array partition
- Contest
- TLE_Headquarters - round #1
- Language
- C++17 (G++ 13.2.0)
- Submit At
- 2024-03-27 16:33:10
- Judged At
- 2024-11-11 03:38:32
- Judged By
- Score
- 100
- Total Time
- 16ms
- Peak Memory
- 1.324 MiB