結果

問題 No.634 硬貨の枚数1
ユーザー bennkei0327bennkei0327
提出日時 2018-01-24 23:00:47
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,177 bytes
コンパイル時間 607 ms
コンパイル使用メモリ 68,972 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-27 02:29:52
合計ジャッジ時間 6,391 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 15 ms
4,376 KB
testcase_16 AC 7 ms
4,376 KB
testcase_17 AC 9 ms
4,376 KB
testcase_18 AC 7 ms
4,380 KB
testcase_19 AC 13 ms
4,376 KB
testcase_20 AC 15 ms
4,376 KB
testcase_21 AC 16 ms
4,376 KB
testcase_22 AC 15 ms
4,380 KB
testcase_23 AC 7 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 6 ms
4,376 KB
testcase_36 AC 11 ms
4,380 KB
testcase_37 AC 8 ms
4,380 KB
testcase_38 AC 3 ms
4,376 KB
testcase_39 AC 15 ms
4,380 KB
testcase_40 AC 11 ms
4,376 KB
testcase_41 AC 10 ms
4,376 KB
testcase_42 AC 14 ms
4,376 KB
testcase_43 AC 7 ms
4,376 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 2 ms
4,376 KB
testcase_46 AC 3 ms
4,380 KB
testcase_47 AC 18 ms
4,380 KB
testcase_48 TLE -
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<iostream>
using namespace std;

class en{
  int N;
  int mine[100000];
  int ans;
  int MAX;
  int p;
public:
  en();
  void show();
  void max();
  void cal();
};

en::en()
{
  int n;
  cin >> n;
  N = n;
}

void en::max()
{
  int kane = 1;
  int j = 2;
  int i = 0;

  for(i = 0; ;i++){
    if(N < mine[i-1])
    {
      MAX = mine[i-2];
      p = i - 2;
      break;
    }

    mine[i] = kane;
    kane = kane + j;
    j++;
  }
}

void en::cal()
{
  int saihu;
  int P = p;
  saihu = N;
  int tmp, pre = 0;
  int i = 0;


  while(1){
    while(1){
      tmp = saihu - mine[P];
      if(tmp < 0){
        P = P-1;
      }
      else if(tmp > 0){
        pre++;
        saihu = saihu - mine[P];
      }
      else{
        pre++;
        break;
      }
    }
    i++;
    if(i == 1) ans = pre;
    P = p - i;
    if(ans > pre){
      ans = pre;
    }
    pre = 0;
    saihu = N;

    if(P == 0) break;

  }
/*    P = P - 1;

    if(ans <= pre){
      ans = pre;
    }
    pre = 0;
    saihu = 0;
    if(P == 1){
      break;
    }
  }*/
}

void en::show()
{
  cout << ans << "\n";
}


int main(){

  en kane;
  kane.max();
  kane.cal();
  kane.show();

  return 0;
}
0