Wrong Answer
Code
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> A(n);
for (int i = 0; i < n; i++) {
cin>>A[i];
}
int odd_count = 0,even_count=0;
for (int i = 0; i < n; ++i) {
if (A[i] % 2 == 1) {
odd_count++;
}
else
even_count++;
}
if(odd_count==0){
cout<<(n*(n+1))/2<<endl;
}
else if(even_count==0)
{
cout<<n-1<<endl;
}
else if(even_count!=0 && odd_count!=0) {
cout << odd_count + 1 << endl;
}
else{
cout<<-1<<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:17:08
- Judged At
- 2024-11-11 03:37:14
- Judged By
- Score
- 15
- Total Time
- 2ms
- Peak Memory
- 332.0 KiB