結果

問題 No.1522 Unfairness
ユーザー chocoruskchocorusk
提出日時 2021-06-18 02:21:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 1,243 bytes
コンパイル時間 3,381 ms
コンパイル使用メモリ 190,760 KB
実行使用メモリ 74,496 KB
最終ジャッジ日時 2024-04-29 21:59:03
合計ジャッジ時間 5,164 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 29 ms
23,680 KB
testcase_04 AC 11 ms
10,880 KB
testcase_05 AC 9 ms
9,344 KB
testcase_06 AC 13 ms
12,672 KB
testcase_07 AC 39 ms
30,208 KB
testcase_08 AC 55 ms
46,336 KB
testcase_09 AC 8 ms
8,448 KB
testcase_10 AC 23 ms
21,376 KB
testcase_11 AC 9 ms
8,960 KB
testcase_12 AC 19 ms
16,128 KB
testcase_13 AC 60 ms
47,744 KB
testcase_14 AC 7 ms
6,912 KB
testcase_15 AC 100 ms
74,368 KB
testcase_16 AC 101 ms
74,240 KB
testcase_17 AC 102 ms
74,368 KB
testcase_18 AC 102 ms
74,368 KB
testcase_19 AC 101 ms
74,240 KB
testcase_20 AC 102 ms
74,496 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint1000000007;
int n, m;
int a[3030];
int dp[2][3030][3030];
int main()
{
    cin>>n>>m;
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a, a+n, greater<int>());
    for(int i=0; i<n; i++){
        for(int j=0; j<=m; j++){
            dp[0][i+1][j]=max(dp[0][i+1][j], dp[0][i][j]);
            if(i+1<n && j>=a[i]-a[i+1]) dp[1][i+1][j]=max(dp[1][i+1][j], dp[0][i][j-(a[i]-a[i+1])]+a[i]);
            dp[0][i+1][j]=max(dp[0][i+1][j], dp[1][i][j]);
            if(i+1<n && j>=a[i]-a[i+1]) dp[1][i+1][j]=max(dp[1][i+1][j], dp[1][i][j-(a[i]-a[i+1])]);
        }
    }
    cout<<max(dp[0][n-1][m], dp[1][n-1][m])<<endl;
    return 0;
}
0