結果

問題 No.1522 Unfairness
ユーザー HaaHaa
提出日時 2021-05-28 22:26:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 881 bytes
コンパイル時間 2,174 ms
コンパイル使用メモリ 169,340 KB
実行使用メモリ 153,856 KB
最終ジャッジ日時 2024-04-25 00:28:10
合計ジャッジ時間 5,873 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
153,728 KB
testcase_01 AC 105 ms
153,600 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 135 ms
153,856 KB
testcase_21 AC 105 ms
153,600 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 106 ms
153,728 KB
testcase_25 AC 105 ms
153,600 KB
testcase_26 WA -
testcase_27 AC 110 ms
153,600 KB
testcase_28 AC 109 ms
153,600 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
constexpr ll MOD=1000000007;
constexpr ll INF=2e18;

int main(){
    int n, m; cin >> n >> m;
    VI a(n); REP(i,n) cin >> a[i];
    sort(ALL(a));
    ll dp[3100][3100][2]={0};
    ll ans=0;
    REP(i,n-1){
        for(int j=0;j<=m;j++){
            if(j+(a[i+1]-a[i])>m)
                break;
            dp[i+1][j+(a[i+1]-a[i])][1]=max(dp[i+1][j+(a[i+1]-a[i])][1],dp[i][j][0]+a[i+1]);
            dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][0]);
            dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][1]);
        }
        for(int j=0;j<=m;j++){
            ans=max(ans,dp[i+1][j][0]);
            ans=max(ans,dp[i+1][j][1]);
        }
    }
    cout << ans << endl;
}
0