結果
問題 |
No.1083 余りの余り
|
ユーザー |
|
提出日時 | 2024-12-10 23:13:11 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 401 ms / 3,000 ms |
コード長 | 1,119 bytes |
コンパイル時間 | 3,411 ms |
コンパイル使用メモリ | 251,960 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-10 23:13:19 |
合計ジャッジ時間 | 6,860 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 31 |
ソースコード
#ifndef LOCAL #include <bits/stdc++.h> using namespace std; #define debug(...) (void(0)) #else #include "algo/debug.h" #endif void solve() { int N, K; cin >> N >> K; vector<int> A(N); for (int i = 0; i < N; i++) { cin >> A[i]; } int sol = [&]() -> int { int ans = 0; int amin = 1e9; for (int i = 0; i < N; i++) amin = min(amin, A[i]); for (unsigned bit = 0; bit < (1u << N); bit++) { vector<int> X; bool f = false; for (int i = 0; i < N; i++) if (bit >> i & 1) { X.push_back(A[i]); f |= A[i] == amin; } if (!f) X.push_back(amin); sort(X.begin(), X.end(), greater<>{}); int cur = K; for (unsigned i = 0; i < X.size(); i++) cur %= X[i]; ans = max(ans, cur); } return ans; }(); cout << sol << endl; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int tt = 1; // std::cin >> tt; while (tt--) { solve(); } }