結果
| 問題 |
No.634 硬貨の枚数1
|
| コンテスト | |
| ユーザー |
merom686
|
| 提出日時 | 2018-01-19 21:54:20 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 714 bytes |
| コンパイル時間 | 1,041 ms |
| コンパイル使用メモリ | 75,252 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-25 18:53:43 |
| 合計ジャッジ時間 | 3,137 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 WA * 34 |
ソースコード
#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 = 5000;
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;
}
merom686