結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,388 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 WA -
testcase_13 AC 78 ms
4,380 KB
testcase_14 WA -
testcase_15 AC 286 ms
4,384 KB
testcase_16 AC 240 ms
4,380 KB
testcase_17 AC 576 ms
4,384 KB
testcase_18 WA -
testcase_19 AC 224 ms
4,384 KB
testcase_20 WA -
testcase_21 AC 912 ms
4,384 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 WA -
testcase_43 RE -
testcase_44 WA -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 WA -
testcase_49 WA -
testcase_50 RE -
testcase_51 RE -
testcase_52 WA -
testcase_53 RE -
testcase_54 RE -
testcase_55 WA -
testcase_56 AC 2 ms
4,384 KB
testcase_57 AC 1 ms
4,380 KB
testcase_58 AC 1 ms
4,384 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) return 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) break;
    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++;
  }

  return -1;
}

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