結果
問題 | No.412 花火大会 |
ユーザー |
![]() |
提出日時 | 2021-02-06 03:04:28 |
言語 | C++17(clang) (17.0.6 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 681 bytes |
コンパイル時間 | 2,245 ms |
コンパイル使用メモリ | 130,128 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-02 14:46:38 |
合計ジャッジ時間 | 1,468 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 18 |
ソースコード
#include <algorithm> #include <iostream> #include <vector> #include <set> int main() { std::vector<int> a(3); for (auto &e : a) { std::cin >> e; } std::sort(a.begin(), a.end()); size_t n; std::cin >> n; std::vector<int> b(n); for (auto &e : b) { std::cin >> e; } std::sort(b.begin(), b.end()); std::vector<std::vector<int>> dp(n + 1, std::vector<int>(4, 0)); dp[0][0] = 1; for (size_t i = 1; i < n + 1; i++) for (size_t j = 0; j < 4; j++) { if (j < 3 && a[j] <= b[i - 1]) { dp[i][j + 1] += dp[i - 1][j]; dp[i][j] += dp[i - 1][j]; } else { dp[i][j] += 2 * dp[i - 1][j]; } } std::cout << dp[n][3] << std::endl; }