結果

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

ソースコード

diff #
raw source code

//Bismillah
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define nl cout<<"\n";
#define YN(condition) cout<<(condition?"YES":"NO")
#define yn(condition) cout<<(condition?"Yes":"No")

#define int long long
#define lint __int128
#define ll long long
#define ld long double
#define pii pair<int,int>
const int inf = 1e17;
const int MOD = 1000000007;

#define ac(n) array<char,n>
#define vi vector<int>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define vpi vector<pair<int,int>>
#define vvi vector<vector<int>>
#define mp map<int,int>
#define pq priority_queue<int>
#define pqmin priority_queue<int, vector<int>, greater<int>>
#define pqminpair priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>

#define f(i,s,e) for(int i=s;i<e;i++)
#define fn(i,s,e) for(int i=s;i>=e;i--)
#define printv(vec) for(auto &value: vec) cout<<value<<" ";
#define inputv(vec) for(auto &value: vec) cin>>value;

#define pb push_back
#define pp pop_back
#define all(s) s.begin(), s.end()
#define sa(vec) sort(vec.begin(), vec.end())
#define sd(vec) sort(vec.begin(), vec.end(), [](int a, int b){return a>b;})

template <typename T>
using ordered_set = tree<
    T,           // key type
    null_type,   // mapped type (null => set)
    less<T>,     // ordering
    rb_tree_tag, // red-black tree
    tree_order_statistics_node_update>;
// .find_by_order(k) returns iterator of kth smallest element (0 based)
// .order_of_key(k) returns number of elements < x

template <typename A, typename B>
istream& operator>>(istream &in, pair<A,B> &p) {
    in >> p.first >> p.second;
    return in;
}
template <typename T>
istream& operator>>(istream &in, vector<T> &v) {
    for (auto &x : v) in >> x;
    return in;
}
template <typename A, typename B>
istream& operator>>(istream &in, vector<pair<A,B>> &vp) {
    for (auto &p : vp) in >> p.first >> p.second;
    return in;
}
template <typename A, typename B>
ostream& operator<<(ostream &out, const pair<A,B> &p) {
    out << p.first << " " << p.second;
    return out;
}
template <typename T>
ostream& operator<<(ostream &out, const vector<T> &v) {
    for (auto &x : v) out << x << " ";
    return out;
}
template <typename A, typename B>
ostream& operator<<(ostream &out, const vector<pair<A,B>> &vp) {
    for (auto &p : vp) out << p.first << " " << p.second << "\n";
    return out;
}

#define fastnuces ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int t = 1;
int test=0;
void solve(){
    int n, k;
    cin>>n>>k;
    vi arr(n);
    cin>>arr;
    vi pre(n), post(n);
    pre[0] = arr[0];
    f(i, 1, n)  pre[i] = arr[i]*pre[i-1];
    post[n-1] = arr[n-1];
    fn(i, n-2, 0)   post[i] = arr[i]*post[i+1];
    int ans = pre[n-1];
    f(i, 0, n){
        int temp = 1;
        if(i)   temp*=pre[i-1];
        if(i<n-1)   temp*=post[i+1];
        temp*=arr[i] - k;
        ans = min(ans, temp);
    }
    cout<<ans;
}
signed main() {
    fastnuces;
    cin >> t;
    while (t--) {
        test++;
        solve();
        nl
    }
    return 0;
}
0