結果
問題 | No.411 昇順昇順ソート |
ユーザー |
|
提出日時 | 2016-08-12 23:00:06 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 518 bytes |
コンパイル時間 | 1,539 ms |
コンパイル使用メモリ | 165,388 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-07 15:41:55 |
合計ジャッジ時間 | 2,376 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; int memo[21][21]; int solve(int n, int k) { if (memo[n][k]) return memo[n][k]; if(n == 2 && k == 1) return 0; if (k == 1) { int ans = 0; for (int i = 1; i < n; i++) ans += solve(n - 1, i); memo[n][k] = ans; return ans; } memo[n][k] = 1 << (n - k); return memo[n][k]; } int main() { cin.tie(0); ios::sync_with_stdio(false); int n, k; cin >> n >> k; cout << solve(n, k) << "\n"; return 0; }