Submission

Status:

[PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: tha_smith

Problemset: Bored Cat

Language: cpp

Time: 0.009 second

Submitted On: 2025-10-08 22:04:20

#include <iostream>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n,sum=0;
	cin >> n;
	int num[n];
	for(int i=0; i<n; i++) {
		cin >> num[i];
	}
	
	if(n%2==0) {
		for(int i=0; i<n; i++) { //pairing numbers
		//cout << num[i] << endl;
		    if(i%2==0) {  //starts with 0
		    	sum+=num[i];
		    	//cout << "even" << sum << endl;
			}
			else {
				sum-=num[i];
				//cout << "odd" << sum << endl;
			}
	    }
	    if(sum==0) {  //all pair
	    	cout << n;
		}
		else {
			cout << n-1;
		}
	}
	else { //there isn't a possibility of an even amount of matching number
		cout << n;
	}
}