結果
| 問題 |
No.2429 Happiest Tabehodai Ways
|
| コンテスト | |
| ユーザー |
shobonvip
|
| 提出日時 | 2023-08-18 22:28:43 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,683 bytes |
| コンパイル時間 | 3,581 ms |
| コンパイル使用メモリ | 253,060 KB |
| 最終ジャッジ日時 | 2025-02-16 10:19:20 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 WA * 11 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/
/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/
typedef long long ll;
#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)
template <typename T> bool chmin(T &a, const T &b) {
if (a <= b) return false;
a = b;
return true;
}
template <typename T> bool chmax(T &a, const T &b) {
if (a >= b) return false;
a = b;
return true;
}
template <typename T> T max(vector<T> &a){
assert(!a.empty());
T ret = a[0];
for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
return ret;
}
template <typename T> T min(vector<T> &a){
assert(!a.empty());
T ret = a[0];
for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
return ret;
}
template <typename T> T sum(vector<T> &a){
T ret = 0;
for (int i=0; i<(int)a.size(); i++) ret += a[i];
return ret;
}
int main(){
int n, k; cin >> n >> k;
vector<pair<int,mint>> dp(k+1, pair(-1, 0));
dp[0] = pair(0, 1);
vector<int> c(n), d(n);
rep(i,0,n) cin >> c[i];
rep(i,0,n) cin >> d[i];
rep(j,0,k+1){
rep(i,0,n){
if (j+c[i] <= k){
if (dp[j+c[i]].first < dp[j].first + d[i]){
dp[j+c[i]].first = dp[j].first + d[i];
dp[j+c[i]].second = dp[j].second;
}else if (dp[j+c[i]].first == dp[j].first + d[i]){
dp[j+c[i]].second += dp[j].second;
}
}
}
}
int mt = 0;
mint ans = 0;
rep(i,0,k+1){
if (dp[i].first >= 0){
mt = dp[i].first;
ans = dp[i].second;
}
}
cout << mt << '\n';
cout << ans.val() << '\n';
}
shobonvip