結果
| 問題 | No.3471 ジャッジサーバーの負荷分散 |
| コンテスト | |
| ユーザー |
ks2m
|
| 提出日時 | 2026-03-06 22:37:36 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 646 ms / 2,000 ms |
| コード長 | 775 bytes |
| 記録 | |
| コンパイル時間 | 2,561 ms |
| コンパイル使用メモリ | 87,740 KB |
| 実行使用メモリ | 68,536 KB |
| 最終ジャッジ日時 | 2026-03-06 22:37:49 |
| 合計ジャッジ時間 | 8,948 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 |
ソースコード
import java.util.PriorityQueue;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int[] t = new int[n];
for (int i = 0; i < n; i++) {
t[i] = sc.nextInt();
}
sc.close();
PriorityQueue<Obj> que = new PriorityQueue<>((o1, o2) -> {
if (o1.v != o2.v) {
return Long.compare(o1.v, o2.v);
}
return o1.i - o2.i;
});
for (int i = 0; i < m; i++) {
Obj o = new Obj();
o.i = i;
que.add(o);
}
long ans = 0;
for (int i = 0; i < n; i++) {
Obj o = que.poll();
o.v += t[i];
que.add(o);
ans = Math.max(ans, o.v);
}
System.out.println(ans);
}
static class Obj {
int i;
long v;
}
}
ks2m