結果

問題 No.3288 Sloppy Land Grading
コンテスト
ユーザー 13d0ccc0-b63b-11f0-9490-db448702d40f
提出日時 2025-11-01 19:24:31
言語 TypeScript
(5.7.2)
結果
AC  
実行時間 570 ms / 2,000 ms
コード長 2,011 bytes
コンパイル時間 7,636 ms
コンパイル使用メモリ 265,828 KB
実行使用メモリ 110,856 KB
最終ジャッジ日時 2025-11-01 19:24:48
合計ジャッジ時間 15,714 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

import * as fs from 'fs';

let inputs = '';
let inputArray: string[];
let currentIndex = 0;

let outputBuffer = '';

function next() {
    return inputArray[currentIndex++];
}
function nextNum() {
    return +next();
}
function nextBigInt() {
    return BigInt(next());
}
function nexts(length: number) {
    const arr = [];
    for (let i = 0; i < length; ++i) arr[i] = next();
    return arr;
}
function nextNums(length: number) {
    const arr = [];
    for (let i = 0; i < length; ++i) arr[i] = nextNum();
    return arr;
}
function nextBigInts(length: number) {
    const arr = [];
    for (let i = 0; i < length; ++i) arr[i] = nextBigInt();
    return arr;
}

function print(out: string | number | bigint): void;
function print<T>(out: Array<T>, separator: string): void;
function print<T>(out: string | number | bigint | Array<T>, separator?: string) {
    if (Array.isArray(out)) {
        outputBuffer += out.join(separator);
    } else {
        outputBuffer += out;
    }
}

function println(out: string | number | bigint): void;
function println<T>(out: Array<T>, separator: string): void;
function println<T>(out: string | number | bigint | Array<T>, separator?: string) {
    if (Array.isArray(out)) {
        print(out, separator || '');
    } else {
        print(out);
    }
    print('\n');
}

function flush() {
    console.log(outputBuffer.trim());
}

function getMin(x: BigInt, y: BigInt): BigInt {
    if (x > y) {
        return y;
    } else {
        return x;
    }
}

inputs = fs.readFileSync('/dev/stdin', 'utf8');
inputArray = inputs.split(/\s/);
main();
flush();

function main() {
    const t = nextNum();
    for (let index = 0; index < t; index++) {
        const [a, b, c, x, y, z] = nextNums(6);
        const posa = BigInt(Math.abs(b - a) * y + Math.abs(c - a) * z);
        const posb = BigInt(Math.abs(b - a) * x + Math.abs(c - b) * z);
        const posc = BigInt(Math.abs(c - a) * x + Math.abs(c - b) * y);
        println(`${getMin(posa, getMin(posb, posc))}`);
    }
}
0