結果

問題 No.1522 Unfairness
ユーザー 👑 NachiaNachia
提出日時 2021-05-13 23:29:21
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 785 bytes
コンパイル時間 1,158 ms
コンパイル使用メモリ 80,216 KB
実行使用メモリ 73,856 KB
最終ジャッジ日時 2023-08-12 07:23:56
合計ジャッジ時間 3,512 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
73,716 KB
testcase_01 AC 21 ms
73,792 KB
testcase_02 AC 21 ms
73,720 KB
testcase_03 AC 28 ms
73,756 KB
testcase_04 AC 23 ms
73,744 KB
testcase_05 AC 22 ms
73,776 KB
testcase_06 AC 22 ms
73,728 KB
testcase_07 AC 31 ms
73,736 KB
testcase_08 AC 31 ms
73,740 KB
testcase_09 AC 22 ms
73,732 KB
testcase_10 AC 24 ms
73,756 KB
testcase_11 AC 22 ms
73,720 KB
testcase_12 AC 26 ms
73,836 KB
testcase_13 AC 36 ms
73,776 KB
testcase_14 AC 22 ms
73,800 KB
testcase_15 AC 49 ms
73,788 KB
testcase_16 AC 48 ms
73,756 KB
testcase_17 AC 47 ms
73,780 KB
testcase_18 AC 48 ms
73,788 KB
testcase_19 AC 49 ms
73,744 KB
testcase_20 AC 50 ms
73,780 KB
testcase_21 AC 21 ms
73,708 KB
testcase_22 AC 21 ms
73,736 KB
testcase_23 AC 21 ms
73,704 KB
testcase_24 AC 22 ms
73,756 KB
testcase_25 AC 21 ms
73,784 KB
testcase_26 AC 21 ms
73,716 KB
testcase_27 AC 21 ms
73,744 KB
testcase_28 AC 21 ms
73,856 KB
testcase_29 AC 22 ms
73,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

const ll INF = 1001001001001001001;

ll dp[3001][3001] = {};


int main(){
  int N, M; cin >> N >> M;
  vector<ll> A(N);
  rep(i,N) cin >> A[i];
  sort(A.begin(),A.end());

  rep(i,3001) rep(j,3001) dp[i][j] = -INF;
  rep(s,3001) dp[0][s] = 0;
  rep(i,N+1) rep(s,M+1){
    if(i >= 1) dp[i][s] = max(dp[i][s], dp[i-1][s]);
    if(i >= 2) if(A[i-1]-A[i-2] <= s) dp[i][s] = max(dp[i][s], dp[i-2][s - (A[i-1]-A[i-2])] + A[i-1]);
  }

  cout << dp[N][M] << "\n";
  return 0;
}


struct ios_do_not_sync{
  ios_do_not_sync(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} ios_do_not_sync_instance;

0