結果

問題 No.634 硬貨の枚数1
ユーザー kwkm0429kwkm0429
提出日時 2018-01-19 23:21:14
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,003 bytes
コンパイル時間 1,094 ms
コンパイル使用メモリ 147,064 KB
実行使用メモリ 814,592 KB
最終ジャッジ日時 2023-08-26 18:59:40
合計ジャッジ時間 5,924 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 9 ms
13,892 KB
testcase_03 AC 4 ms
7,116 KB
testcase_04 AC 4 ms
6,108 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 4 ms
7,568 KB
testcase_07 AC 3 ms
5,332 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 6 ms
8,744 KB
testcase_10 AC 5 ms
7,356 KB
testcase_11 AC 2 ms
4,492 KB
testcase_12 AC 3 ms
6,880 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 AC 6 ms
7,616 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 4 ms
7,196 KB
testcase_27 AC 3 ms
4,780 KB
testcase_28 AC 4 ms
8,452 KB
testcase_29 AC 5 ms
8,872 KB
testcase_30 AC 5 ms
7,320 KB
testcase_31 AC 5 ms
8,028 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 3 ms
5,244 KB
testcase_34 MLE -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define EPS (1e-7)

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

int vx[]={0,1,0,-1};
int vy[]={1,0,-1,0};

int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int MAX=1e9;

int main(){
	int n;
	cin>>n;
	int ans=0;
	vector<int> c;
	for(int k=1;k*(k+1)<=2*n;k++){
		c.push_back(k*(k+1)/2);
	}
	int m=c.size();
	int dp[m+1][n+1];
	for(int i=0;i<m;i++){
		for(int j=0;j<=n;j++){
			dp[i][j]=10000;
		}
	}
	for(int i=0;i<m;i++)dp[i][0]=0;

	for(int i=1;i<=m;i++){
		for(int j=0;j<=n;j++){
			if(j<c[i-1])dp[i][j]=dp[i-1][j];
			dp[i][j]=min(dp[i-1][j],dp[i][j-c[i-1]]+1);
		}
	}
	/*
	for(int i=0;i<=m;i++){
		for(int j=0;j<=n;j++){
			cout<<dp[i][j]<<" ";
		}
		cout<<endl;
	}
	*/
	cout<<dp[m][n]<<endl;
	return 0;
}
0