Submission #2124491


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] ++;
      prog[c][t + 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 400
Code Size 3748 Byte
Status AC
Exec Time 131 ms
Memory 34644 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 22
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 AC 128 ms 33036 KB
02.txt AC 126 ms 30764 KB
03.txt AC 129 ms 33224 KB
04.txt AC 129 ms 31956 KB
05.txt AC 115 ms 20620 KB
06.txt AC 126 ms 32840 KB
07.txt AC 122 ms 34228 KB
08.txt AC 96 ms 31316 KB
09.txt AC 130 ms 30932 KB
10.txt AC 131 ms 32832 KB
11.txt AC 128 ms 31572 KB
12.txt AC 92 ms 23892 KB
13.txt AC 93 ms 31060 KB
14.txt AC 92 ms 30676 KB
15.txt AC 105 ms 29268 KB
16.txt AC 127 ms 34388 KB
17.txt AC 128 ms 30976 KB
18.txt AC 129 ms 33088 KB
19.txt AC 130 ms 34644 KB
sample_01.txt AC 76 ms 19540 KB
sample_02.txt AC 90 ms 23892 KB
sample_03.txt AC 78 ms 21076 KB