Compile Error
foo.cc: In function 'int main()': foo.cc:13:13: error: 'oddCount' was not declared in this scope 13 | oddCount++; | ^~~~~~~~ foo.cc:16:13: error: 'even_count' was not declared in this scope 16 | even_count++; | ^~~~~~~~~~ foo.cc:19:8: error: 'oddCount' was not declared in this scope 19 | if(oddCount % 2 != 0) { | ^~~~~~~~ foo.cc:22:32: error: 'even_count' was not declared in this scope 22 | cout << oddCount / 2 + even_count << endl; | ^~~~~~~~~~
Code
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
int main() {
ll N;
cin >> N;
ll arr[N];
ll odd= 0,even=0;
for(ll i = 0; i < N; i++) {
cin >> arr[i];
if(arr[i] % 2 != 0) {
oddCount++;
}
else{
even_count++;
}
}
if(oddCount % 2 != 0) {
cout << -1 << endl;
} else {
cout << oddCount / 2 + even_count << 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 16:33:17
- Judged At
- 2024-11-11 03:38:32
- Judged By
- Score
- 0
- Total Time
- 0ms
- Peak Memory
- 0 Bytes