結果

問題 No.634 硬貨の枚数1
ユーザー koyoprokoyopro
提出日時 2020-01-30 22:58:36
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,640 bytes
コンパイル時間 2,112 ms
コンパイル使用メモリ 150,764 KB
実行使用メモリ 292,536 KB
最終ジャッジ日時 2023-10-14 08:57:40
合計ジャッジ時間 126,717 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
159,336 KB
testcase_01 AC 44 ms
158,980 KB
testcase_02 AC 1,862 ms
290,648 KB
testcase_03 AC 1,796 ms
291,048 KB
testcase_04 AC 1,785 ms
291,300 KB
testcase_05 AC 397 ms
192,484 KB
testcase_06 AC 1,791 ms
292,040 KB
testcase_07 AC 1,798 ms
291,400 KB
testcase_08 AC 817 ms
225,288 KB
testcase_09 AC 1,810 ms
291,360 KB
testcase_10 AC 1,790 ms
291,060 KB
testcase_11 AC 1,328 ms
291,352 KB
testcase_12 AC 1,789 ms
291,064 KB
testcase_13 AC 918 ms
225,404 KB
testcase_14 AC 1,799 ms
291,680 KB
testcase_15 AC 1,821 ms
291,628 KB
testcase_16 AC 1,803 ms
292,236 KB
testcase_17 AC 1,799 ms
290,932 KB
testcase_18 AC 1,797 ms
291,620 KB
testcase_19 AC 1,812 ms
292,260 KB
testcase_20 AC 1,804 ms
291,692 KB
testcase_21 AC 1,833 ms
291,128 KB
testcase_22 AC 1,814 ms
291,124 KB
testcase_23 AC 1,807 ms
291,304 KB
testcase_24 AC 1,792 ms
292,428 KB
testcase_25 AC 523 ms
225,660 KB
testcase_26 AC 1,779 ms
290,956 KB
testcase_27 AC 1,708 ms
291,324 KB
testcase_28 AC 1,783 ms
290,848 KB
testcase_29 AC 1,779 ms
290,964 KB
testcase_30 AC 1,783 ms
290,872 KB
testcase_31 AC 1,800 ms
290,960 KB
testcase_32 AC 274 ms
192,888 KB
testcase_33 AC 1,789 ms
291,760 KB
testcase_34 AC 1,795 ms
291,760 KB
testcase_35 AC 1,792 ms
292,536 KB
testcase_36 AC 1,805 ms
291,304 KB
testcase_37 AC 1,845 ms
291,052 KB
testcase_38 AC 1,810 ms
291,940 KB
testcase_39 AC 1,813 ms
291,448 KB
testcase_40 AC 1,805 ms
291,368 KB
testcase_41 AC 1,808 ms
291,256 KB
testcase_42 AC 1,811 ms
290,796 KB
testcase_43 AC 1,790 ms
290,904 KB
testcase_44 AC 47 ms
159,524 KB
testcase_45 AC 1,816 ms
291,172 KB
testcase_46 AC 1,800 ms
291,872 KB
testcase_47 AC 1,806 ms
292,504 KB
testcase_48 WA -
testcase_49 AC 1,792 ms
292,320 KB
testcase_50 AC 1,810 ms
290,608 KB
testcase_51 AC 1,802 ms
290,740 KB
testcase_52 AC 44 ms
158,872 KB
testcase_53 AC 45 ms
159,056 KB
testcase_54 AC 46 ms
159,384 KB
testcase_55 AC 1,820 ms
291,296 KB
testcase_56 AC 1,816 ms
291,316 KB
testcase_57 AC 1,810 ms
290,652 KB
testcase_58 AC 1,816 ms
292,348 KB
testcase_59 AC 1,804 ms
291,752 KB
testcase_60 AC 1,803 ms
291,592 KB
testcase_61 AC 1,806 ms
291,924 KB
testcase_62 AC 1,813 ms
291,052 KB
testcase_63 AC 1,814 ms
291,968 KB
testcase_64 AC 1,825 ms
292,120 KB
testcase_65 AC 1,848 ms
291,248 KB
testcase_66 AC 1,818 ms
290,924 KB
testcase_67 AC 1,824 ms
290,828 KB
testcase_68 AC 1,817 ms
291,044 KB
testcase_69 AC 1,817 ms
291,624 KB
testcase_70 AC 1,808 ms
290,656 KB
testcase_71 AC 1,826 ms
291,156 KB
testcase_72 AC 1,819 ms
290,912 KB
testcase_73 AC 1,811 ms
292,460 KB
testcase_74 AC 1,829 ms
291,716 KB
testcase_75 AC 1,810 ms
290,996 KB
testcase_76 AC 1,793 ms
292,048 KB
testcase_77 AC 1,802 ms
290,764 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) {
        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;
    }
    sort(ALL(D));
    C[0] = 0;
    
    cout << check(N) << endl;
}
0