結果

問題 No.1656 Recuperation
ユーザー karinohitokarinohito
提出日時 2021-08-30 23:53:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,493 bytes
コンパイル時間 1,374 ms
コンパイル使用メモリ 170,124 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-03 10:22:44
合計ジャッジ時間 2,037 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using Graph = vector<vector<ll>>;
vector<int> a = { 1, 14, 32, 51, 51, 51, 243, 419, 750, 910 };
ll N, K;

vll A;
// index が条件を満たすかどうか
bool isOK(int index) {
    ll k = 0;
    rep(i, N) {
        k += max(0ll, A[i] - index);
    }
    return (k < K);
}

// 汎用的な二分探索のテンプレ
int binary_search() {
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 1e9; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる! */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;

        if (isOK(mid)) right = mid;
        else left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}
   ll mod = 998244353;
ll inv(ll N) {
    ll a = N, b = mod, c = 1, d = 0;
    while (b > 0) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        c -= t * d;
        swap(c, d);

    }
    c %= mod;
    if (c < 0)c += mod;
    return c;

}
int main() {
    ll T;
    cin>>T;
    rep(t,T){
        ll A,B;
        cin>>A>>B;
        cout<<(A+1)*B<<endl;
    }

}
0