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 1119. Metro

For some reason I kept getting run time error at 1. Help plz?
Posted by Yifei Xu 8 Jun 2013 02:43
import java.util.*;

class Path {
    //Fields

    public int X;
    public int Y;
    private int MaxPath;

    //Constructor
    public Path(int x, int y) {
        this.X = x;
        this.Y = y;
        this.MaxPath = 0;
    }

    //Methods
    public int getMaxPath(List<Path> pathList) {
        if (this.MaxPath != 0) {
            return this.MaxPath;
        }
        int max = 0;
        for (Path p : pathList) {
            if ((p.X > this.X) && (p.Y > this.Y)) {
                int subMaxPath = p.getMaxPath(pathList);
                if (max < subMaxPath) {
                    max = subMaxPath;
                }
            }
        }
        this.MaxPath = max + 1;
        return this.MaxPath;
    }
}

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int K = scanner.nextInt();

        List<Path> pathList = new ArrayList<Path>();
        for (int i = 0; i < K; i++) {
            pathList.add(new Path(scanner.nextInt(), scanner.nextInt()));
        }

        int max = 0;
        for (Path p : pathList) {
            int curTrend = p.getMaxPath(pathList);
            if (curTrend > max) {
                max = curTrend;
            }
        }

        System.out.format("%.0f", 100 * (N + M) - 100 * max * (2 - Math.sqrt(2)));
    }
}

It works fine on my computer. Am I using a different version of Java?
Re: For some reason I kept getting run time error at 1. Help plz?
Posted by SVVS 15 Apr 2014 00:27
after output data need end of line!
Re: For some reason I kept getting run time error at 1. Help plz?
Posted by SimonAbdullah 16 Apr 2014 22:49
I'm having the same problem when I use JAVA :-(