結果

問題 No.1083 余りの余り
ユーザー snrnsidysnrnsidy
提出日時 2021-10-05 01:34:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 705 bytes
コンパイル時間 1,996 ms
コンパイル使用メモリ 200,292 KB
実行使用メモリ 85,524 KB
最終ジャッジ日時 2023-09-30 07:55:56
合計ジャッジ時間 11,305 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
85,300 KB
testcase_01 AC 24 ms
85,296 KB
testcase_02 AC 23 ms
85,420 KB
testcase_03 AC 23 ms
85,312 KB
testcase_04 AC 23 ms
85,500 KB
testcase_05 AC 233 ms
85,364 KB
testcase_06 AC 23 ms
85,320 KB
testcase_07 AC 23 ms
85,364 KB
testcase_08 AC 23 ms
85,372 KB
testcase_09 AC 23 ms
85,376 KB
testcase_10 AC 23 ms
85,316 KB
testcase_11 AC 23 ms
85,296 KB
testcase_12 AC 23 ms
85,284 KB
testcase_13 AC 23 ms
85,304 KB
testcase_14 AC 23 ms
85,472 KB
testcase_15 AC 23 ms
85,288 KB
testcase_16 AC 23 ms
85,280 KB
testcase_17 AC 23 ms
85,380 KB
testcase_18 AC 483 ms
85,284 KB
testcase_19 AC 233 ms
85,460 KB
testcase_20 AC 25 ms
85,316 KB
testcase_21 AC 43 ms
85,496 KB
testcase_22 AC 24 ms
85,376 KB
testcase_23 AC 1,021 ms
85,480 KB
testcase_24 AC 1,024 ms
85,284 KB
testcase_25 AC 1,024 ms
85,304 KB
testcase_26 AC 1,020 ms
85,288 KB
testcase_27 AC 23 ms
85,440 KB
testcase_28 WA -
testcase_29 AC 24 ms
85,288 KB
testcase_30 AC 23 ms
85,524 KB
testcase_31 AC 23 ms
85,284 KB
testcase_32 AC 24 ms
85,380 KB
testcase_33 AC 1,023 ms
85,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int dp[1<<20][20];

int main(void) 
{
	cin.tie(0);
	ios::sync_with_stdio(false);

  int n,k,t;
  vector <int> a;

  cin >> n >> k;

  for(int i=0;i<n;i++)
  {
    cin >> t;
    a.push_back(t);
  }

  memset(dp,-1,sizeof(dp));

  for(int i=0;i<n;i++)
  {
    dp[(1<<i)][i] = k%a[i];
  }

  for(int i=0;i<(1<<n);i++)
  {
    for(int j=0;j<n;j++)
    {
      if(dp[i][j]==-1) continue;
      for(int k=0;k<n;k++)
      {
        if((i&(1<<k))) continue;
        dp[i | (1<<k)][k] = max(dp[i | (1<<k)][k],(dp[i][j]%a[k]));
      }
    }
  }

  int res = 0;

  for(int i=0;i<n;i++)
  {
    res = max(res,dp[(1<<n)-1][i]);
  }
  cout << res << '\n';

	return 0;
}
0