結果
| 問題 | No.3077 Goodstuff Deck Builder(Hard) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-31 16:53:13 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 864 bytes |
| 記録 | |
| コンパイル時間 | 550 ms |
| コンパイル使用メモリ | 105,852 KB |
| 実行使用メモリ | 165,888 KB |
| 最終ジャッジ日時 | 2026-03-31 16:54:03 |
| 合計ジャッジ時間 | 6,629 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 6 TLE * 1 -- * 50 |
ソースコード
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
#include<ctime>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>
using namespace std;
typedef long long LL;
const int M=1e7+10;
int n,m;
pair<int,int> a[10005];
LL dp[2][M];
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i].first>>a[i].second;
}
sort(a+1,a+1+n);
reverse(a+1,a+1+n);
for(int i=0;i<n;i++){
memset(dp[(i+1)&1],0xc0,sizeof dp[0]);
int c=a[i+1].first, d=a[i+1].second;
for(int j=0;j<=m;j++){
dp[(i+1)&1][j] = max(dp[(i+1)&1][j],dp[i&1][j]);
if(j>=c) dp[(i+1)&1][(j-c)/2] = max(dp[(i+1)&1][(j-c)/2],dp[i&1][j]+d);
}
}
LL ans=0;
for(int j=0;j<=m;j++){
ans=max(ans,dp[n&1][j]);
}
cout<<ans<<endl;
return 0;
}