結果

問題 No.1083 余りの余り
ユーザー AnchorBluesAnchorBlues
提出日時 2023-03-08 18:20:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 98 ms / 3,000 ms
コード長 1,394 bytes
コンパイル時間 1,836 ms
コンパイル使用メモリ 173,456 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 06:00:19
合計ジャッジ時間 3,645 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 23 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 48 ms
4,348 KB
testcase_19 AC 24 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 4 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 98 ms
4,348 KB
testcase_24 AC 97 ms
4,348 KB
testcase_25 AC 98 ms
4,348 KB
testcase_26 AC 97 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 97 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 3 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 2 ms
4,348 KB
testcase_33 AC 96 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
template <typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;

const ll INF = 1LL << 60;

template <class T>
void chmax(T& a, T b) {
    if (b > a) a = b;
}
template <class T>
void chmin(T& a, T b) {
    if (b < a) a = b;
}

template <typename T, typename S>
std::ostream& operator<<(std::ostream& os, const pair<T, S>& x) noexcept {
    return os << "(" << x.first << ", " << x.second << ")";
}

template <typename T>
void print_vector(vector<T> a) {
    cout << '[';
    for (int i = 0; i < a.size(); i++) {
        cout << a[i];
        if (i != a.size() - 1) {
            cout << ", ";
        }
    }
    cout << ']' << endl;
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    ll M = 1 << N;
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    ll ret = 0;
    for (int bit = 0; bit < (1 << (N - 1)); ++bit) {
        std::vector<int> S;
        ll X = K;
        for (int i = 0; i < N; ++i) {
            if (bit & (1 << i)) X %= A[i];
        }
        X %= A[N - 1];
        chmax(ret, X);
    }
    std::cout << ret << "\n";
    return 0;
}
0