結果

問題 No.1104 オンライン点呼
ユーザー beetbeet
提出日時 2020-07-03 22:03:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 799 bytes
コンパイル時間 2,049 ms
コンパイル使用メモリ 204,820 KB
実行使用メモリ 5,212 KB
最終ジャッジ日時 2023-10-17 03:20:48
合計ジャッジ時間 6,019 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 AC 2 ms
4,348 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
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;}
using Int = long long;
const char newl = '\n';


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n,k;
  cin>>n>>k;
  vector<Int> as(n+2),bs(n+2);
  for(Int i=0;i<n;i++) cin>>as[i];
  for(Int i=0;i<n;i++) cin>>bs[i];

  if(n==1) drop(0);
  assert(n<=10);

  const Int INF = 1e18;
  vector<Int> dp(n+2,INF);
  dp[0]=0;
  for(Int i=0;i<n;i++){
    chmin(dp[i+1],dp[i]+as[i]+bs[i+1]);
    chmin(dp[i+2],dp[i]+as[i]+bs[i+2]+k);
  }
  cout<<*max_element(dp.begin(),dp.begin()+n)<<newl;
  return 0;
}
0