编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#3289 #1021. jwp的区间游戏 Compile Error 0 0 ms 0 K C++ 17 / 2.0 K LittleFall 2019-06-26 14:18:35
显示原始代码
import java.util.*;
import java.io.*;

public
class IntervalGame {
    static class InputReader {
    public
        BufferedReader reader;
    public
        StringTokenizer tokenizer;

    public
        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

    public
        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    public
        int nextInt() { return Integer.parseInt(next()); }

    }

    class Interval {
    public
        int left;
    public
        int right;
        Interval() {}
        Interval(int left, int right) {
            this.left = left;
            this.right = right;
        }
    }

    public static int n;
public
    static ArrayList<Interval> ranges = new ArrayList();

public
    static void main(String[] args) throws IOException {
        InputReader reader = new InputReader(System.in);
        n = reader.nextInt();

        IntervalGame test = new IntervalGame();
        for (int i = 0; i < n; i++) {
            int left = reader.nextInt();
            int right = reader.nextInt();
            ranges.add(test.new Interval(left, right));
        }
        ranges.sort(new Comparator<Interval>() {
            public int compare(Interval p1, Interval p2) {
                return p1.right - p2.right;
    }
        });

        int k = 0;
        int i = 0;
        int j = 0;
        while (i < n && j < n) {
            while (j < n && ranges.get(i).right >= ranges.get(j).left) {
                j++;
            }
            k++;
            i = j;
        }
        System.out.println(k);
        }
        }

编译信息

/sandbox/1/a.cpp:1:1: error: 'import' does not name a type; did you mean 'short'?
 import java.util.*;
 ^~~~~~
 short
/sandbox/1/a.cpp:2:1: error: 'import' does not name a type; did you mean 'short'?
 import java.io.*;
 ^~~~~~
 short
/sandbox/1/a.cpp:4:1: error: expected unqualified-id before 'public'
 public class IntervalGame {
 ^~~~~~