結果

問題 No.1297 銅像
ユーザー beetbeet
提出日時 2020-11-20 22:20:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,165 bytes
コンパイル時間 3,363 ms
コンパイル使用メモリ 216,320 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2023-09-30 19:28:35
合計ジャッジ時間 9,265 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#pragma GCC optimize ("O3")
#pragma GCC target ("avx2") // or sse4
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
using namespace std;

using Int = long long;
const char newl = '\n';

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;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}

//INSERT ABOVE HERE
using ull = unsigned long long;
const int MAX = 1e5+10;
ull as[MAX];
ull bs[MAX];

const ull INF = 1e19;
ull dp[MAX];
ull vs[MAX]={};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int n,c;
  cin>>n>>c;
  for(int i=0;i<n;i++) cin>>as[i]>>bs[i];


  fill(dp,dp+MAX,INF);
  for(int i=1;i<=n;i++) vs[i]=vs[i-1]+i*c;

  dp[0]=0;
  for(int i=0;i<n;i++){
    ull a=as[i];
    ull cur=dp[i];

    for(int p=0;p<i;p++)
      chmin(cur,dp[p]+a*(i-p)+vs[i-p]);

    cur+=bs[i];

    // [-, j]
    for(int j=i;j<n;j++)
      chmin(dp[j+1],cur+=a+(j-i)*c);
  }

  cout<<dp[n]<<endl;
  return 0;
}
0