結果
| 問題 | No.634 硬貨の枚数1 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-09-10 01:52:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 600 bytes |
| 記録 | |
| コンパイル時間 | 1,873 ms |
| コンパイル使用メモリ | 166,608 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-25 16:10:35 |
| 合計ジャッジ時間 | 4,701 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 WA * 58 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const ll inf = 100100100100100;
const int mod = 1e9+7;
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
int n;
cin >> n;
int i = 0;
while(i*(i+1)/2 <= n) i++;
n -= i*(i-1)/2;
int dp[n+1];
rep(i,0,n+1) dp[i] = i;
rep(i,2,1000){
rep(j,0,n+1){
if(j + (i*(i+1)/2) < n+1){
dp[j + (i*(i+1)/2)] = min(dp[j+(i*(i+1)/2)], dp[j] + 1);
}
}
}
cout << dp[n] + 1 << endl;
}