結果

問題 No.2741 Balanced Choice
ユーザー butsurizukibutsurizuki
提出日時 2024-04-21 02:56:11
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 695 bytes
コンパイル時間 3,592 ms
コンパイル使用メモリ 275,276 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-21 02:56:15
合計ジャッジ時間 4,433 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
6,812 KB
testcase_01 AC 28 ms
6,940 KB
testcase_02 AC 28 ms
6,944 KB
testcase_03 AC 30 ms
6,940 KB
testcase_04 AC 31 ms
6,944 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 11 ms
6,944 KB
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;

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

  long long n,tw,d;
  cin >> n >> tw >> d;
  vector<long long> d0(tw+1,0);
  vector<long long> d1(tw+1,0);

  while(n>0){
    n--;
    long long t,w,v;
    cin >> t >> w >> v;
    if(t==0){
      for(long long i=tw-w;i>=0;i--){
        d0[i+w]=max(d0[i+w],d0[i]+v);
      }
    }
    else{
      for(long long i=tw-w;i>=0;i--){
        d1[i+w]=max(d1[i+w],d1[i]+v);
      }
    }
  }

  long long res=0;
  for(long long i=0;i<=tw;i++){
    for(long long j=0;i+j<=tw;j++){
      if(abs(i-j)<=d){
        res=max(res,d0[i]+d1[j]);
      }
    }
  }
  cout << res << "\n";
  return 0;
}
0