結果

問題 No.3433 [Cherry 8th Tune A] ADD OIL!
コンテスト
ユーザー vjudge1
提出日時 2026-02-09 01:52:43
言語 C++17(gcc12)
(gcc 12.4.0 + boost 1.89.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 774 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,993 ms
コンパイル使用メモリ 205,496 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-02-09 01:52:46
合計ジャッジ時間 3,126 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#ifdef ONPC
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#ifdef ONPC
#include "debug.hpp"
#else
#define debug(...) 42
#endif
using namespace std;
#define int long long
#define nl "\n"

void solve()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int &val : a)
    {
        cin >> val;
    }
    int curr = 1;
    for (int i = 0; i < n; ++i)
    {
        curr *= a[i];
    }
    int mini = LLONG_MAX;
    for (int i = 0; i < n; ++i)
    {
        int temp = curr / a[i];
        mini = min(mini, temp * (max(0ll, a[i] - k)));
    }
    cout << mini << nl;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    cin >> t;
    for (int i = 0; i < t; ++i)
    {
        debug(i);
        solve();
    }
    return 0;
}
0