UTMOPR - Editorial

IT WORKS SOME TIMES…YOUR CODE WORKS BUT U DON’T KNOW HOW IT WORK…
VERY WEAK TEST CASES…IT IS NOT GOOD AFTER SEEING VERY LOOSE TEST CASE…

This person is down voting answers to get his on top. How fascinating.

2 Likes

hi I have corrected your code and pointed out your mistake …hope it is helpful to u…happy coding…

nothing is short same as previous…):stuck_out_tongue:

Since you declared sum as int sum=0 , but each number can be uptil 10^9 and total numbers at max can be 10^3 so sum becomes 10^12 which overflows int data type. So I hope using long long will help.

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll t;
	cin >> t;
	while(t--) {
		int n, k;
		cin >> n >> k;
		int x[n];
		ll sum = 0;
		for(int i = 0; i < n; i++) {
			cin >> x[i];
			sum += x[i];
		}
		if(sum % 2 == 0 && k == 1) {
			cout << "odd" << endl;
		} else {
			cout << "even" << endl;
		}
	}
}