結果

問題 No.2567 A_1 > A_2 > ... > A_N
ユーザー tentententen
提出日時 2023-12-04 17:43:22
言語 Java21
(openjdk 21)
結果
AC  
実行時間 478 ms / 2,000 ms
コード長 2,192 bytes
コンパイル時間 3,280 ms
コンパイル使用メモリ 90,912 KB
実行使用メモリ 73,744 KB
最終ジャッジ日時 2023-12-04 17:43:32
合計ジャッジ時間 9,545 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
54,752 KB
testcase_01 AC 285 ms
69,300 KB
testcase_02 AC 318 ms
68,892 KB
testcase_03 AC 317 ms
66,668 KB
testcase_04 AC 341 ms
73,744 KB
testcase_05 AC 286 ms
69,868 KB
testcase_06 AC 478 ms
65,364 KB
testcase_07 AC 463 ms
67,504 KB
testcase_08 AC 464 ms
64,976 KB
testcase_09 AC 452 ms
67,480 KB
testcase_10 AC 445 ms
67,448 KB
testcase_11 AC 77 ms
55,020 KB
testcase_12 AC 78 ms
54,896 KB
testcase_13 AC 70 ms
54,776 KB
testcase_14 AC 51 ms
53,968 KB
testcase_15 AC 68 ms
54,916 KB
testcase_16 AC 68 ms
52,904 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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 q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        while (q-- > 0) {
            int n = sc.nextInt();
            long t = sc.nextLong();
            if (n * (n + 1L) / 2 > t) {
                sb.append("-1\n");
                continue;
            }
            long total = t - n * (n + 1L) / 2;
            long div = total / n;
            long mod = total % n;
            long[] ans = new long[n];
            for (int i = 0; i < n; i++) {
                ans[i] = n - i + div;
                if (i < mod) {
                    ans[i]++;
                }
            }
            sb.append(String.join(" ", Arrays.stream(ans).mapToObj(String::valueOf).toArray(String[]::new))).append("\n");
        }
        System.out.print(sb);
    }
}
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();
    }
    
}
0