I got wrong answer when I used int to store the values of n, a, b and total score of both, but as soon as I switched int to long my answer was accepted. why I dont know.
please help.
Contest Link: Equinox Strings | CodeChef
Code:
import java.util.Scanner;
public class EQUINOX {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int t = s.nextInt();
while(t-- > 0){
long n = s.nextLong();
long a = s.nextLong();
long b = s.nextLong();
long STotal = 0, ATotal = 0;
s.nextLine();
for(int i=0;i<n;i++){
char ch = s.nextLine().charAt(0);
if(ch == 'E' || ch == 'Q' || ch == 'U' || ch == 'I' || ch == 'N' || ch == 'O' || ch == 'X'){
STotal += a;
}else{
ATotal += b;
}
}
if(STotal == ATotal){
System.out.println("DRAW");
}else if(ATotal > STotal){
System.out.println("ANURADHA");
}else{
System.out.println("SARTHAK");
}
}
}
}