提出 #72882095


ソースコード 拡げる

/*
 * ------------------------------------------------------------
 * Author: Karan Singh Chauhan
 * © 2025 Karan Singh Chauhan. All rights reserved.
 * ------------------------------------------------------------
 * Competitive Programming Template (Java 21)
 * ------------------------------------------------------------
 * Features:
 *  -> Ultra-fast I/O (FastReader + PrintWriter)
 *  -> Common Math Utilities (GCD, LCM, Modular Arithmetic)
 *  -> Pair record + Custom sorting helpers
 *  -> Debug mode (auto-disabled for online judge)
 *  -> Auto file input/output (input.txt → output.txt)
 * ------------------------------------------------------------
 */

import java.io.*;
import java.util.*;

public class Main {

    static final long MOD = 1_000_000_007L;
    static final int INF = (int) 1e9;
    static final long LINF = (long) 1e18;

    static FastReader sc;
    static PrintWriter out;
    static boolean DEBUG = System.getProperty("ONLINE_JUDGE") == null;

    public static void main(String[] args) throws Exception {
        if (DEBUG) {
            try {
                sc = new FastReader(new FileInputStream("input.txt"));
                out = new PrintWriter(new FileOutputStream("output.txt"));
            } catch (FileNotFoundException e) {
                System.err.println(" input.txt not found! Falling back to standard input/output.");
                sc = new FastReader(System.in);
                out = new PrintWriter(new BufferedOutputStream(System.out));
            }
        } else {
            sc = new FastReader(System.in);
            out = new PrintWriter(new BufferedOutputStream(System.out));
        }

        int t = 1;
        // Uncomment below for multiple test cases

        while (t-- > 0) solve();

        out.flush();
        out.close();
    }

    static void solve() {
        //  Write your code here ↓↓↓
        int n = in();
        int k = in();

        int count = n;
        int beans = 0;
        int ans = 0;

        if(n >= k){
            System.out.println(0);
            return;
        }

        while (beans < k) {
            beans += count;
            ans++;
            count++;
        }
        System.out.println(ans - 1);
    }

    // ------------------------------------------------------------
    //  Smaller Reader For Fast Input
    // ------------------------------------------------------------

    static int in(){
        return sc.nextInt();
    }

    static long ll(){
        return sc.nextLong();
    }

    static String ss(){
        return sc.next();
    }

    static int[] ia(int n){
        return sc.readIntArray(n);
    }

    static long[] la(int n){
        return sc.readLongArray(n);
    }

    // ------------------------------------------------------------
    //  MATH UTILITIES
    // ------------------------------------------------------------
    static long gcd(long a, long b) {
        while (b != 0) { long tmp = a % b; a = b; b = tmp; } return a;
    }
    static long lcm(long a, long b) { return a / gcd(a, b) * b; }
    static long modAdd(long a, long b) { long res = (a + b) % MOD; return res < 0 ? res + MOD : res; }
    static long modSub(long a, long b) { long res = (a - b) % MOD; return res < 0 ? res + MOD : res; }
    static long modMul(long a, long b) { return (a % MOD) * (b % MOD) % MOD; }
    static long modPow(long base, long exp) { long res = 1; base %= MOD; while (exp > 0) { if ((exp & 1) == 1) res = (res * base) % MOD; base = (base * base) % MOD; exp >>= 1; } return res; }
    static long modInverse(long a) { return modPow(a, MOD - 2); }

    // ------------------------------------------------------------
    //  HELPER RECORDS / STRUCTURES (Java 21)
    // ------------------------------------------------------------
    record Pair(int x, int y) implements Comparable<Pair> {
        @Override
        public int compareTo(Pair o) {
            int cmp = Integer.compare(x, o.x);
            return cmp != 0 ? cmp : Integer.compare(y, o.y);
        }
        @Override
        public String toString() { return "(" + x + ", " + y + ")"; }
    }

    // ------------------------------------------------------------
    // ⚡ FAST INPUT READER
    // ------------------------------------------------------------
    static class FastReader {
        private final byte[] buffer = new byte[1 << 16];
        private int ptr = 0, len = 0;
        private final InputStream in;

        FastReader(InputStream stream) { in = stream; }

        private int readByte() {
            if (ptr >= len) {
                ptr = 0;
                try { len = in.read(buffer); if (len <= 0) return -1; } catch (IOException e) { return -1; }
            }
            return buffer[ptr++];
        }

        String next() {
            int c; StringBuilder sb = new StringBuilder();
            do { c = readByte(); } while (c <= ' ');
            while (c > ' ') { sb.append((char) c); c = readByte(); }
            return sb.toString();
        }

        int nextInt() {
            int c, sign = 1, val = 0;
            do { c = readByte(); } while (c <= ' ');
            if (c == '-') { sign = -1; c = readByte(); }
            while (c > ' ') { val = val * 10 + (c - '0'); c = readByte(); }
            return val * sign;
        }

        long nextLong() {
            int c, sign = 1; long val = 0;
            do { c = readByte(); } while (c <= ' ');
            if (c == '-') { sign = -1; c = readByte(); }
            while (c > ' ') { val = val * 10 + (c - '0'); c = readByte(); }
            return val * sign;
        }

        double nextDouble() { return Double.parseDouble(next()); }

        int[] readIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; }
        long[] readLongArray(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); return a; }
    }

    // ------------------------------------------------------------
    //  DEBUG UTILITIES
    // ------------------------------------------------------------
    static void debug(Object... o) { if (DEBUG) out.println(Arrays.deepToString(o)); }
}

提出情報

提出日時
問題 B - Setsubun
ユーザ KaranChauhan
言語 Java24 (OpenJDK 24.0.2)
得点 200
コード長 6331 Byte
結果 AC
実行時間 47 ms
メモリ 38576 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 3
AC × 27
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt
All sample_01.txt, sample_02.txt, sample_03.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt
ケース名 結果 実行時間 メモリ
sample_01.txt AC 47 ms 38216 KiB
sample_02.txt AC 42 ms 38188 KiB
sample_03.txt AC 43 ms 38464 KiB
test_01.txt AC 43 ms 38376 KiB
test_02.txt AC 44 ms 38576 KiB
test_03.txt AC 42 ms 38352 KiB
test_04.txt AC 43 ms 38576 KiB
test_05.txt AC 41 ms 38224 KiB
test_06.txt AC 42 ms 38464 KiB
test_07.txt AC 41 ms 38464 KiB
test_08.txt AC 42 ms 38472 KiB
test_09.txt AC 42 ms 38168 KiB
test_10.txt AC 43 ms 38148 KiB
test_11.txt AC 42 ms 37920 KiB
test_12.txt AC 42 ms 37980 KiB
test_13.txt AC 42 ms 38252 KiB
test_14.txt AC 43 ms 38460 KiB
test_15.txt AC 43 ms 38148 KiB
test_16.txt AC 43 ms 38432 KiB
test_17.txt AC 43 ms 38124 KiB
test_18.txt AC 41 ms 38120 KiB
test_19.txt AC 41 ms 38260 KiB
test_20.txt AC 42 ms 38272 KiB
test_21.txt AC 42 ms 38172 KiB
test_22.txt AC 42 ms 38040 KiB
test_23.txt AC 42 ms 38252 KiB
test_24.txt AC 43 ms 38220 KiB