結果
問題 | No.2482 Sandglasses |
ユーザー | tenten |
提出日時 | 2023-09-25 15:44:00 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 1,021 ms / 2,000 ms |
コード長 | 3,132 bytes |
コンパイル時間 | 3,666 ms |
コンパイル使用メモリ | 92,180 KB |
実行使用メモリ | 72,216 KB |
最終ジャッジ日時 | 2024-04-28 09:05:25 |
合計ジャッジ時間 | 31,275 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 55 ms
37,204 KB |
testcase_01 | AC | 57 ms
37,736 KB |
testcase_02 | AC | 55 ms
37,472 KB |
testcase_03 | AC | 842 ms
71,700 KB |
testcase_04 | AC | 900 ms
72,216 KB |
testcase_05 | AC | 970 ms
71,988 KB |
testcase_06 | AC | 863 ms
70,156 KB |
testcase_07 | AC | 847 ms
69,780 KB |
testcase_08 | AC | 817 ms
71,588 KB |
testcase_09 | AC | 850 ms
71,360 KB |
testcase_10 | AC | 859 ms
71,468 KB |
testcase_11 | AC | 901 ms
70,844 KB |
testcase_12 | AC | 920 ms
70,292 KB |
testcase_13 | AC | 894 ms
69,912 KB |
testcase_14 | AC | 1,002 ms
70,496 KB |
testcase_15 | AC | 993 ms
71,864 KB |
testcase_16 | AC | 918 ms
69,824 KB |
testcase_17 | AC | 1,021 ms
70,220 KB |
testcase_18 | AC | 922 ms
71,160 KB |
testcase_19 | AC | 872 ms
70,872 KB |
testcase_20 | AC | 887 ms
69,760 KB |
testcase_21 | AC | 933 ms
70,576 KB |
testcase_22 | AC | 858 ms
71,180 KB |
testcase_23 | AC | 815 ms
69,924 KB |
testcase_24 | AC | 782 ms
70,148 KB |
testcase_25 | AC | 829 ms
70,488 KB |
testcase_26 | AC | 823 ms
72,024 KB |
testcase_27 | AC | 742 ms
71,348 KB |
ソースコード
import java.io.*; import java.util.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int k = sc.nextInt(); int t = sc.nextInt(); Glass[] glasses = new Glass[n]; for (int i = 0; i < n; i++) { glasses[i] = new Glass(i, sc.next().charAt(0) == 'A'); } for (int i = 0; i < n; i++) { glasses[i].value = sc.nextInt(); } Arrays.sort(glasses); int[] values = new int[n]; for (int i = 0; i < n; i++) { if (glasses[i].isA) { int current = t + k - glasses[i].value; int div = current / k; int mod = current % k; if (div % 2 == 0) { values[i] = k - mod; } else { values[i] = mod; } } else { int current = t + glasses[i].value; int div = current / k; int mod = current % k; if (div % 2 == 0) { values[i] = mod; } else { values[i] = k - mod; } } } Arrays.sort(values); int[] ans = new int[n]; for (int i = 0; i < n; i++) { ans[glasses[i].idx] = values[i]; } System.out.println(String.join(" ", Arrays.stream(ans).mapToObj(String::valueOf).toArray(String[]::new))); } static class Glass implements Comparable<Glass> { int idx; boolean isA; int value; public Glass(int idx, boolean isA) { this.idx = idx; this.isA = isA; } public int compareTo(Glass another) { return value - another.value; } } } class Utilities { static String arrayToLineString(Object[] arr) { return Arrays.stream(arr).map(x -> x.toString()).collect(Collectors.joining("\n")); } static String arrayToLineString(int[] arr) { return String.join("\n", Arrays.stream(arr).mapToObj(String::valueOf).toArray(String[]::new)); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public int[] nextIntArray() throws Exception { return Stream.of(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray(); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }