結果

問題 No.853 河原の石
ユーザー beetbeet
提出日時 2019-07-26 23:13:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,001 bytes
コンパイル時間 2,193 ms
コンパイル使用メモリ 201,292 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-15 04:17:42
合計ジャッジ時間 16,041 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 RE -
testcase_13 AC 77 ms
4,384 KB
testcase_14 RE -
testcase_15 AC 288 ms
4,380 KB
testcase_16 AC 240 ms
4,376 KB
testcase_17 AC 572 ms
4,380 KB
testcase_18 RE -
testcase_19 AC 223 ms
4,380 KB
testcase_20 RE -
testcase_21 AC 915 ms
4,384 KB
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 RE -
testcase_55 RE -
testcase_56 RE -
testcase_57 AC 2 ms
4,380 KB
testcase_58 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
Int solve2(Int h, Int w){
  w=abs(w);
  Int ans=0;
  if(h>=w){
    ans+=(h-(w-1));
    h=w-1;
  }

  for(Int i=1;i<=h;i<<=1){
    Int j=min((i<<1)-1,h);
    Int len=j-i+1;
    ans+=len*(w/i);
    Int res=w%i;
    ans+=res;
  }
  return ans;
}

Int solve3(Int h,Int w){
  if(w>=1e7) assert(0);

  auto start=clock();
  Int num=0;
  vector<Int> cnt(w+1,0);
  cnt[0]=h;
  while(1){
    if((double)(clock()-start)/CLOCKS_PER_SEC>=1.0) assert(0);
    if(cnt[w]==h){
      return num;
    }
    for(Int i=0;i<w;i++){
      if(cnt[i]==0) continue;
      Int j=i+cnt[i];
      chmin(j,w);
      cnt[i]--;
      cnt[j]++;
      break;
    }
    num++;
  }
  assert(0);
  return -1;
}

signed main(){
  Int h,w;
  cin>>h>>w;
  cout<<solve3(h,w)<<endl;
  return 0;
}
0