結果
| 問題 |
No.1956 猫の額
|
| ユーザー |
|
| 提出日時 | 2022-05-23 22:04:38 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,799 bytes |
| コンパイル時間 | 1,772 ms |
| コンパイル使用メモリ | 115,456 KB |
| 実行使用メモリ | 23,040 KB |
| 最終ジャッジ日時 | 2024-09-20 14:04:16 |
| 合計ジャッジ時間 | 5,682 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 WA * 1 RE * 9 MLE * 5 |
ソースコード
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using Int = long long;
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
int N, M, K;
int A[95];
Int dp[45][100'010];
int main() {
for (; ~scanf("%d%d%d", &N, &M, &K); ) {
for (int i = 0; i < N; ++i) {
scanf("%d", &A[i]);
}
sort(A, A + N);
int sumA = 0;
for (int i = 0; i < N; ++i) {
sumA += A[i];
}
const bool rev = chmin(K, N - K);
#ifdef LOCAL
memset(dp, 0, sizeof(dp));
#endif
dp[0][0] = 1;
for (int i = 0; i < N; ++i) {
for (int k = K; --k >= 0; ) {
for (int x = 0; x + A[i] <= sumA; ++x) {
dp[k + 1][x + A[i]] += dp[k][x];
}
}
}
if (rev) {
reverse(dp[K], dp[K] + (sumA + 1));
}
for (int x = 1; x <= sumA; ++x) {
if (x > 1) printf(" ");
printf("%lld", dp[K][x] % M);
}
puts("");
}
return 0;
}