結果
問題 |
No.2999 Long Long Friedrice
|
ユーザー |
|
提出日時 | 2025-04-22 22:47:57 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 880 bytes |
コンパイル時間 | 1,201 ms |
コンパイル使用メモリ | 104,360 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-04-22 22:48:14 |
合計ジャッジ時間 | 11,191 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 WA * 2 |
other | AC * 14 WA * 18 TLE * 1 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; const int MAX_H = 500005; // 最大身長 int main() { int N; cin >> N; vector<int> A(N), B(N); for (int i = 0; i < N; ++i) cin >> A[i]; for (int i = 0; i < N; ++i) cin >> B[i]; vector<bool> dp(MAX_H, false); dp[1] = true; // 初期身長は1cm for (int i = 0; i < N; ++i) { vector<bool> next_dp = dp; for (int h = 0; h < MAX_H; ++h) { if (dp[h] && h >= A[i]) { int new_h = h + B[i]; if (new_h < MAX_H) { next_dp[new_h] = true; } } } dp = next_dp; } // dp配列から最大の身長を探す for (int h = MAX_H - 1; h >= 0; --h) { if (dp[h]) { cout << h << endl; return 0; } } }