ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1644. A Whole Lot of Walnuts

why doesn't it work? java
Posted by Argin 27 Feb 2020 21:10
import java.util.Scanner;
public class javasucc {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int h = 2, s = 10;
        for(int i=0; i<n; i++) {
            int a = in.nextInt();
            String b = in.next();
            if(b=="hungry"){
                if(a>h) {h = a;}
            }
            else if(b=="satisfied"){
                if(a<s) {s = a;}
            }
        }
        if(h >= s) System.out.println("Inconsistent");
        else System.out.println(s);
    }
}

and the problem is that program doesn't want to do if and i can't change s to a
Re: why doesn't it work? java
Posted by ToadMonster 28 Feb 2020 14:38
1) WA1, task example isn't passed - it's shame to cry "help" on WA1. You should better debug your code.
2) https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java
Re: why doesn't it work? java
Posted by Argin 12 Mar 2020 20:58
1) I wasn't crying for help though but just was wondering why
2) Thanks for the link, the problem was actually in "=="