結果
問題 |
No.634 硬貨の枚数1
|
ユーザー |
![]() |
提出日時 | 2018-01-19 22:01:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 715 bytes |
コンパイル時間 | 584 ms |
コンパイル使用メモリ | 75,240 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-25 18:55:34 |
合計ジャッジ時間 | 3,406 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 70 WA * 5 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cstdio> #include <cstring> #include <cmath> using namespace std; int main() { int n; cin >> n; int m = 55000; vector<int> a(m); a[0] = 0; for (int i = 1; i < m; i++) { int x = 1 << 30; for (int k = 1;; k++) { int l = k * (k + 1) / 2; if (l > i) break; x = min(x, a[i - l] + 1); } a[i] = x; } int i = n; int x = 1 << 30; for (int k = 1;; k++) { int l = k * (k + 1) / 2; if (l > i) break; if (i - l >= m) continue; x = min(x, a[i - l] + 1); } cout << x << endl; return 0; }