結果
| 問題 |
No.1083 余りの余り
|
| コンテスト | |
| ユーザー |
yel_ow
|
| 提出日時 | 2024-11-30 09:18:54 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 878 bytes |
| コンパイル時間 | 3,542 ms |
| コンパイル使用メモリ | 260,816 KB |
| 実行使用メモリ | 58,400 KB |
| 最終ジャッジ日時 | 2024-11-30 09:19:35 |
| 合計ジャッジ時間 | 40,979 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 1 TLE * 9 |
ソースコード
//#include <monsterenergy>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int MAX = 1e9;
const int MIN = -1*1e9;
const ll MAXLL = 1e18;
const ll MINLL = -1*1e18;
ll N,Ans = MIN;
vector<ll> V(21);
map<pair<int,vector<bool>>,bool> F;
void DFS(vector<bool> A, int last, ll K)
{
if(F[{last,A}]) return;
F[{last,A}] = true;
if(K <= Ans) return;
bool f = false;
for(int i = 0; i < N; i++)
{
if(A[i]) continue;
f = true;
A[i] = true;
DFS(A,i,K%V[i]);
A[i] = false;
}
if(!f)
{
Ans = max(Ans,K);
return;
}
return;
}
int main()
{
ll K; cin >> N >> K;
for(int i = 0; i < N; i++) cin >> V[i];
vector<bool> A(21);
DFS(A,-1,K);
cout << Ans << endl;
return 0;
}
yel_ow