結果
| 問題 | No.616 へんなソート |
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2023-06-23 23:04:07 |
| 言語 | C++17(clang) (clang++ 22.1.2 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 81 ms / 2,000 ms |
| コード長 | 898 bytes |
| 記録 | |
| コンパイル時間 | 3,550 ms |
| コンパイル使用メモリ | 146,432 KB |
| 実行使用メモリ | 56,544 KB |
| 最終ジャッジ日時 | 2026-03-21 19:51:00 |
| 合計ジャッジ時間 | 1,961 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
コンパイルメッセージ
main.cpp:21:9: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
21 | int A[N];
| ^
main.cpp:21:9: note: read of non-const variable 'N' is not allowed in a constant expression
main.cpp:19:7: note: declared here
19 | int N, K;
| ^
main.cpp:26:17: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
26 | int dp[N + 1][K + N + 1];
| ^~~~~~~~~
main.cpp:26:17: 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:26:10: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
26 | int dp[N + 1][K + N + 1];
| ^~~~~
main.cpp:26:10: note: read of non-const variable 'N' is not allowed in a constant expression
main.cpp:19:7: note: declared here
19 | int N, K;
| ^
3 warnings generated.
ソースコード
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <climits>
#include <map>
#include <queue>
#include <set>
#include <cstring>
#include <vector>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
int main() {
int N, K;
cin >> N >> K;
int A[N];
for (int i = 0; i < N; ++i) {
cin >> A[i];
}
int dp[N + 1][K + N + 1];
memset(dp, 0, sizeof(dp));
for (int k = 0; k <= K; ++k) {
dp[0][k] = 1;
}
for (int i = 0; i < N; ++i) {
for (int j = 0; j <= K; ++j) {
if (j - i - 1 >= 0) {
dp[i + 1][j] += (dp[i][j] - dp[i][j - i - 1] + MOD);
dp[i + 1][j] %= MOD;
} else {
dp[i + 1][j] += dp[i][j];
dp[i + 1][j] %= MOD;
}
if (j != 0) dp[i + 1][j] += dp[i + 1][j - 1];
dp[i + 1][j] %= MOD;
}
}
cout << dp[N][K] << endl;
return 0;
}
siman