結果
| 問題 | No.1238 選抜クラス |
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2020-12-29 08:35:53 |
| 言語 | C++17(clang) (clang++ 22.1.2 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 906 bytes |
| 記録 | |
| コンパイル時間 | 6,206 ms |
| コンパイル使用メモリ | 149,880 KB |
| 実行使用メモリ | 11,392 KB |
| 最終ジャッジ日時 | 2026-04-20 16:39:52 |
| 合計ジャッジ時間 | 6,834 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 WA * 2 RE * 16 |
コンパイルメッセージ
main.cpp:27:16: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
27 | ll dp[K + 1][K * 100 + 1];
| ^~~~~~~~~~~
main.cpp:27:16: note: read of non-const variable 'K' is not allowed in a constant expression
main.cpp:19:10: note: declared here
19 | int N, K;
| ^
main.cpp:27:9: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
27 | ll dp[K + 1][K * 100 + 1];
| ^~~~~
main.cpp:27:9: note: read of non-const variable 'K' is not allowed in a constant expression
main.cpp:19:10: note: declared here
19 | int N, K;
| ^
2 warnings 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;
const ll MOD = 1000000007;
int main() {
int N, K;
cin >> N >> K;
vector<int> A(N);
for (int i = 0; i < N; ++i) {
cin >> A[i];
}
ll dp[K + 1][K * 100 + 1];
memset(dp, 0, sizeof(dp));
dp[0][0] = 1;
for (int i = 0; i < N; ++i) {
int a = A[i];
for (int k = i; k >= 0; --k) {
for (int j = 0; j <= 100 * i; ++j) {
if (dp[k][j] == 0) continue;
dp[k + 1][j + a] += dp[k][j];
dp[k + 1][j + a] %= MOD;
}
}
}
ll ans = 0;
for (int i = 1; i <= N; ++i) {
for (int j = i * K; j <= 100 * N; ++j) {
ans += dp[i][j];
ans %= MOD;
}
}
cout << ans << endl;
return 0;
}
siman