Submission #1308108


Source Code Expand

import java.io.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private void solve(Scanner sc) {
        int K = sc.nextInt();
        int S = sc.nextInt();
 
        int cnt = 0;
        for (int x = 0; x <= K; ++x) {
            for (int y = 0; y <= K; ++y) {
                int z = S - x - y;
                if (0 <= z && z <= K) {
                    ++cnt;
                }
            }
        }
        _out.println(cnt);
    }
    private long C(long n, long r) {
        long res = 1;
        for (long i = n; i > n - r; --i) {
            res *= i;
        }
        for (long i = r; i > 1; --i) {
            res /= i;
        }
        return res;
    }
    private long P(long n, long r) {
        long res = 1;
        for (long i = n; i > n - r; --i) {
            res *= i;
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Submission Info

Submission Time
Task B - Sum of Three Integers
User unirita135
Language Java8 (OpenJDK 1.8.0)
Score 200
Code Size 1582 Byte
Status AC
Exec Time 113 ms
Memory 23764 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 10
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All sample_01.txt, sample_02.txt, subtask_1_01.txt, subtask_1_02.txt, subtask_1_03.txt, subtask_1_04.txt, subtask_1_05.txt, subtask_1_06.txt, subtask_1_07.txt, subtask_1_08.txt
Case Name Status Exec Time Memory
sample_01.txt AC 95 ms 21328 KB
sample_02.txt AC 93 ms 20564 KB
subtask_1_01.txt AC 113 ms 17620 KB
subtask_1_02.txt AC 97 ms 19796 KB
subtask_1_03.txt AC 104 ms 19284 KB
subtask_1_04.txt AC 99 ms 23764 KB
subtask_1_05.txt AC 95 ms 21712 KB
subtask_1_06.txt AC 100 ms 17620 KB
subtask_1_07.txt AC 104 ms 23380 KB
subtask_1_08.txt AC 106 ms 19796 KB