結果

問題 No.634 硬貨の枚数1
ユーザー koyoprokoyopro
提出日時 2020-01-30 23:03:57
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,644 bytes
コンパイル時間 1,277 ms
コンパイル使用メモリ 151,356 KB
実行使用メモリ 292,692 KB
最終ジャッジ日時 2023-10-14 09:02:52
合計ジャッジ時間 40,351 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
159,156 KB
testcase_01 AC 46 ms
159,068 KB
testcase_02 TLE -
testcase_03 AC 1,882 ms
290,436 KB
testcase_04 AC 1,889 ms
290,444 KB
testcase_05 AC 428 ms
193,236 KB
testcase_06 AC 1,881 ms
290,588 KB
testcase_07 AC 1,877 ms
290,436 KB
testcase_08 AC 854 ms
224,796 KB
testcase_09 AC 1,886 ms
290,584 KB
testcase_10 AC 1,892 ms
290,584 KB
testcase_11 AC 1,421 ms
290,456 KB
testcase_12 AC 1,878 ms
290,416 KB
testcase_13 AC 954 ms
225,244 KB
testcase_14 AC 1,925 ms
291,124 KB
testcase_15 AC 1,932 ms
290,432 KB
testcase_16 AC 1,913 ms
290,600 KB
testcase_17 AC 1,876 ms
290,436 KB
testcase_18 AC 1,896 ms
291,336 KB
testcase_19 AC 1,985 ms
290,416 KB
testcase_20 AC 1,937 ms
291,812 KB
testcase_21 AC 1,902 ms
292,232 KB
testcase_22 AC 1,940 ms
292,296 KB
testcase_23 AC 1,929 ms
292,252 KB
testcase_24 AC 1,894 ms
291,592 KB
testcase_25 AC 558 ms
226,680 KB
testcase_26 AC 1,936 ms
292,068 KB
testcase_27 AC 1,781 ms
292,264 KB
testcase_28 AC 1,886 ms
290,892 KB
testcase_29 AC 1,885 ms
292,520 KB
testcase_30 AC 1,934 ms
292,484 KB
testcase_31 AC 1,887 ms
291,084 KB
testcase_32 AC 280 ms
192,520 KB
testcase_33 AC 1,902 ms
290,964 KB
testcase_34 AC 1,884 ms
291,652 KB
testcase_35 AC 1,880 ms
291,168 KB
testcase_36 AC 1,955 ms
292,560 KB
testcase_37 AC 1,893 ms
291,692 KB
testcase_38 AC 1,886 ms
290,988 KB
testcase_39 AC 1,946 ms
292,140 KB
testcase_40 AC 1,888 ms
291,212 KB
testcase_41 AC 1,882 ms
290,768 KB
testcase_42 AC 1,894 ms
292,620 KB
testcase_43 AC 1,874 ms
290,992 KB
testcase_44 AC 46 ms
159,472 KB
testcase_45 AC 1,881 ms
291,504 KB
testcase_46 AC 1,911 ms
292,008 KB
testcase_47 AC 1,883 ms
291,668 KB
testcase_48 AC 46 ms
159,176 KB
testcase_49 AC 1,887 ms
291,664 KB
testcase_50 AC 1,898 ms
291,788 KB
testcase_51 AC 1,880 ms
291,536 KB
testcase_52 AC 45 ms
159,480 KB
testcase_53 AC 47 ms
159,320 KB
testcase_54 AC 46 ms
159,548 KB
testcase_55 AC 1,902 ms
292,592 KB
testcase_56 AC 1,900 ms
291,016 KB
testcase_57 AC 1,903 ms
290,852 KB
testcase_58 AC 1,886 ms
291,360 KB
testcase_59 AC 1,893 ms
290,920 KB
testcase_60 AC 1,898 ms
291,260 KB
testcase_61 AC 1,890 ms
291,724 KB
testcase_62 AC 1,895 ms
291,860 KB
testcase_63 AC 1,896 ms
291,256 KB
testcase_64 AC 1,894 ms
292,128 KB
testcase_65 AC 1,899 ms
291,312 KB
testcase_66 AC 1,892 ms
291,084 KB
testcase_67 AC 1,892 ms
291,316 KB
testcase_68 AC 1,891 ms
290,828 KB
testcase_69 AC 1,887 ms
291,552 KB
testcase_70 AC 1,940 ms
292,404 KB
testcase_71 AC 1,902 ms
292,692 KB
testcase_72 AC 1,902 ms
292,464 KB
testcase_73 AC 1,904 ms
292,476 KB
testcase_74 AC 1,900 ms
291,248 KB
testcase_75 AC 1,893 ms
291,756 KB
testcase_76 AC 1,886 ms
292,128 KB
testcase_77 AC 1,891 ms
290,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define array2(type, x, y) array<array<type, y>, x>
#define vector2(type) vector<vector<type> >
#define out(...) printf(__VA_ARGS__)

int dxy[] = {0, 1, 0, -1, 0};

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/

int N,M,Q;

int ans;
vector<int> S; // 1枚で払える金額一覧
vector<int> D; // 2枚で払える金額一覧
vector<int> C(2e7, INT_MAX); // SorDに入っている金額のチェック用
int MAX=1e7;

int check(int n) {
    int ret = INT_MAX;
    for (int m:S) {
        if (m > n) break;
        ret = min(ret,1 + C[n-m]);
    }
    for (int m:D) {
        if (m > n) break;
        ret = min(ret,2 + C[n-m]);
    }
    return ret;
}

void solve() {
    cin>>N;
    
    REP(i,N+2) {
        int n = i * (i+1) / 2;
        if (n > MAX) break;
        S.push_back(n);
        C[n] = 1;
    }
    for (int a:S) for (int b:S) {
        int n = a + b;
        if (n > MAX) break;
        if (C[n]==1) continue;
        D.push_back(n);
        C[n] = 2;
    }
    UNIQUE_SORT(D);
    C[0] = 0;
    
    cout << check(N) << endl;
}
0