Tuesday, 15 August 2023

Video Solution for Codeforces Round 893 DIV 2 - Problem A in #JAVA 



Hello fellow programmers,

For those of you who participated in Codeforces Round 893 DIV 2 and were working on Problem A, here is the solution in JAVA



Solution in JAVA 

import java.util.*;

public class test {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();   //for total number of test cases
        for (int i = 0; i < t; i++) {
            int a, b, c;   
            a = sc.nextInt();
            b = sc.nextInt();
            c = sc.nextInt();
            int qwerty = c/2;  
            a = a + c - qwerty;
            b = b + qwerty;
            if(a>b)
            {
                System.out.println("First"); //Anna will win
            }
            else
            {
                System.out.println("Second"); //else Katie
            }
             
    }
    sc.close();
  }
}

No comments:

Post a Comment

Good thoughtful question on Binary search on answers

Problem link:  https://leetcode.com/problems/maximize-score-of-numbers-in-ranges/description/ Solution: //import java.util.Arrays; class So...