結果
| 問題 | No.412 花火大会 |
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2021-08-25 07:55:52 |
| 言語 | C++17(clang) (clang++ 22.1.2 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 905 bytes |
| 記録 | |
| コンパイル時間 | 2,021 ms |
| コンパイル使用メモリ | 152,192 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-11 02:24:54 |
| 合計ジャッジ時間 | 4,783 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 18 |
コンパイルメッセージ
main.cpp:30:9: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
30 | ll dp[N + 1][4];
| ^~~~~
main.cpp:30:9: note: read of non-const variable 'N' is not allowed in a constant expression
main.cpp:22:7: note: declared here
22 | int N;
| ^
1 warning generated.
ソースコード
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
int B, C, D;
cin >> B >> C >> D;
vector<int> S = {B, C, D};
sort(S.begin(), S.end());
int N;
cin >> N;
vector<int> E(N);
for (int i = 0; i < N; ++i) {
cin >> E[i];
}
sort(E.begin(), E.end());
ll dp[N + 1][4];
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
for (int i = 0; i < N; ++i) {
int cnt = 0;
for (int j = 0; j < 3; ++j) {
if (S[j] <= E[i]) ++cnt;
}
for (int j = 0; j < 4; ++j) {
if (j < cnt) {
dp[i + 1][j + 1] += dp[i][j];
dp[i + 1][j] += dp[i][j];
} else {
dp[i + 1][j] += 2 * dp[i][j];
}
}
}
cout << dp[N][3] << endl;
return 0;
}
siman