結果

問題 No.1285 ゴミ捨て
コンテスト
ユーザー キョウチク
提出日時 2022-05-16 15:13:07
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 337 ms / 2,000 ms
コード長 697 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,534 ms
コンパイル使用メモリ 82,820 KB
実行使用メモリ 57,040 KB
最終ジャッジ日時 2026-04-04 11:08:44
合計ジャッジ時間 9,216 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.util.*;
public class Test10 {
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String line;
    line=sc.nextLine();
    int n=Integer.parseInt(line);
    int[] cups=new int[n+1];
    for(int i=0;i<n;i++){
      line=sc.nextLine();
      cups[i]=Integer.parseInt(line);
    }
    cups[n]=Integer.MAX_VALUE;
    Arrays.sort(cups);
    int max=0;
    while(cups[0]<Integer.MAX_VALUE){
      max++;
      int tmp=0;
      for(int i=0;cups[i]<Integer.MAX_VALUE;i++){
        if(tmp<cups[i]){
          tmp=cups[i]+1;
          cups[i]=Integer.MAX_VALUE;
        }
      }
      Arrays.sort(cups);
    }
    System.out.println(max);
    sc.close();
  }
}
0