Hello Programmers In this post, you will know how to solve the Chef and easy problem Codechef Solution.Chef and easy problem Codechef SolutionOne more thing to add, don’t directly look for the solutions, first try to solve the problems of Codechef by yourself. If you find any difficulty after trying several times, then you can look for solutions.ProblemChef and Roma are playing a game. Rules of the game are quite simple. Initially there are N piles of stones on the table. In each turn, a player can choose one pile and remove it from the table. Each player want to maximize the total number of stones removed by him. Chef takes the first turn.Please tell Chef the maximum number of stones he can remove assuming that both players play optimally.InputThe first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.The first line of each test case contains a single integer N denoting the number of piles.The second line contains N space separated integers A1, A2, …, AN denoting the number of stones in each pile.OutputFor each test case, output a single line containg the maximum number of stones that Chef can remove.Constraints1 ≤ Ai ≤ 109Subtask 1 (35 points): T = 10, 1 ≤ N ≤ 1000Subtask 2 (65 points): T = 10, 1 ≤ N ≤ 105ExampleInput: 2 3 1 2 3 3 1 2 1 Output: 4 3Chef and easy problem CodeChef Solutions in JAVAimport java.util.*; class Chef_and_easy_problem { public static void main (String[]args) { Scanner input = new Scanner(System.in); int t = input.nextInt(); while(t-- > 0) { ArrayList<Long> list = new ArrayList<Long>(); int n = input.nextInt(); int temp = n; while(n-- > 0) { list.add(input.nextLong()); } Collections.sort(list, Collections.reverseOrder()); long sum = 0; for (int i = 0 ; i < temp ; i+=2) { sum += list.get(i); } System.out.println(sum); } input.close(); } } Chef and easy problem CodeChef Solutions in CPP#include <bits/stdc++.h> using namespace std; int main () { int b; cin >> b; for (int j = 1; j <= b; j++) { int n; cin >> n; int a[100001]; for (int i = 1; i <= n; i++) { cin >> a[i]; } long long sum = 0; sort(a + 1, a + n + 1, greater<long long>()); for (int i = 1; i <= n; i += 2) { sum += a[i]; } cout << sum << endl; } return 0; }Chef and easy problem CodeChef Solutions in Pythont=int(input()) for i in range(t): n=int(input()) lis=list(map(int,input().split())) lis.sort(reverse=True) j=0 sumi=0 while j<n: if j%2==0: sumi+=lis[j] j+=1 print(sumi) Disclaimer: The above Problem (Chef and easy problem) is generated by CodeChef but the solution is provided by BrokenProgrammers. This tutorial is only for Educational and Learning purpose.Note:- I compile all programs, if there is any case program is not working and showing an error please let me know in the comment section. If you are using adblocker, please disable adblocker because some functions of the site may not work correctly.Next: Maximum Candies Codechef Solution Post navigationChef and His Apartment Dues Codechef Solution Maximum Candies Codechef Solution