Submission #2124474


Source Code Expand

import java.io.*;
import java.util.*;
 
 
public class Main implements Runnable {
 
  public void run() {
    BetterScanner scanner = new BetterScanner(System.in);
  
    int n = scanner.nextInt();
    int mc = scanner.nextInt();

    int[][] prog = new int[mc][100001];
    for (int i = 0 ; i < n ; i ++) {
      int s = scanner.nextInt() - 1;
      int t = scanner.nextInt() - 1;
      int c = scanner.nextInt() - 1;
      prog[c][s] = 1;
      prog[c][t + 1] = -1;
    }
    for (int c = 0 ; c < mc ; c ++) {
      int sum = 0;
      for (int i = 0 ; i < 100001 ; i ++) {
        sum += prog[c][i];
        prog[c][i] = sum;
      }
    }

    int max = 0;
    for (int i = 0 ; i < 100001 ; i ++) {
      int current = 0;
      for (int c = 0 ; c < mc ; c ++) {
        if (prog[c][i] > 0) {
          current ++;
        }
      }
      if (current > max) {
        max = current;
      }
    }
    System.out.println(max);
  }
 
  public static void main(String[] args) {
    Main main = new Main();
    main.run();
  }
 
  // scanner slightly faster than usual ones
  public static class BetterScanner {
 
    private InputStream stream;
    private byte[] buffer = new byte[1024];
    private int pointer = 0;
    private int bufferLength = 0;
 
    public BetterScanner(InputStream stream) {
      this.stream = stream;
    }
 
    private boolean updateBuffer() {
      if (pointer >= bufferLength) {
        pointer = 0;
        try {
          bufferLength = stream.read(buffer);
        } catch (IOException exception) {
          exception.printStackTrace();
        }
        return bufferLength > 0;
      } else {
        return true;
      }
    }
 
    private int read() {
      if (updateBuffer()) {
        return buffer[pointer ++];
      } else {
        return -1;
      }
    }
 
    public boolean hasNext() {
      skipUnprintable();
      return updateBuffer();
    }
 
    private void skipUnprintable() { 
      while (updateBuffer() && !isPrintableChar(buffer[pointer])) {
        pointer ++;
      }
    }
 
    public String next() {
      if (hasNext()) {
        StringBuilder builder = new StringBuilder();
        int codePoint = read();
        while (isPrintableChar(codePoint)) {
          builder.appendCodePoint(codePoint);
          codePoint = read();
        }
        return builder.toString();
      } else {
        throw new NoSuchElementException();
      }
    }
 
    public long nextLong() {
      if (hasNext()) {
        long number = 0;
        boolean minus = false;
        int codePoint = read();
        if (codePoint == '-') {
          minus = true;
          codePoint = read();
        }
        if (codePoint >= '0' && codePoint <= '9') {
          while (true) {
            if (codePoint >= '0' && codePoint <= '9') {
              number *= 10;
              number += codePoint - '0';
            } else if (codePoint < 0 || !isPrintableChar(codePoint)) {
              return (minus) ? -number : number;
            } else {
              throw new NumberFormatException();
            }
            codePoint = read();
          }
        } else {
          throw new NumberFormatException();
        }
      } else {
        throw new NoSuchElementException();
      }
    }
 
    public int nextInt() {
      long number = nextLong();
      if (number >= Integer.MIN_VALUE && number <= Integer.MAX_VALUE) {
        return (int)number;
      } else {
        throw new NumberFormatException();
      }
    }
 
    private boolean isPrintableChar(int codePoint) {
      return codePoint >= 33 && codePoint <= 126;
    }
 
  }
 
}

Submission Info

Submission Time
Task D - Recording
User ziphil
Language Java8 (OpenJDK 1.8.0)
Score 0
Code Size 3751 Byte
Status WA
Exec Time 135 ms
Memory 35144 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 16
WA × 6
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
01.txt WA 134 ms 32192 KB
02.txt WA 130 ms 31828 KB
03.txt WA 133 ms 32076 KB
04.txt WA 131 ms 33160 KB
05.txt AC 107 ms 19924 KB
06.txt WA 126 ms 34132 KB
07.txt WA 119 ms 34516 KB
08.txt AC 95 ms 30804 KB
09.txt AC 132 ms 33048 KB
10.txt AC 132 ms 31512 KB
11.txt AC 133 ms 31800 KB
12.txt AC 93 ms 23636 KB
13.txt AC 94 ms 32980 KB
14.txt AC 93 ms 34004 KB
15.txt AC 92 ms 28756 KB
16.txt AC 135 ms 33204 KB
17.txt AC 131 ms 30928 KB
18.txt AC 135 ms 35144 KB
19.txt AC 132 ms 35088 KB
sample_01.txt AC 88 ms 21588 KB
sample_02.txt AC 90 ms 23892 KB
sample_03.txt AC 89 ms 20436 KB