結果

問題 No.1297 銅像
ユーザー beetbeet
提出日時 2020-11-20 22:35:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 966 bytes
コンパイル時間 3,381 ms
コンパイル使用メモリ 218,568 KB
実行使用メモリ 6,796 KB
最終ジャッジ日時 2023-09-30 19:38:41
合計ジャッジ時間 6,600 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,456 KB
testcase_01 AC 3 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,424 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 AC 9 ms
4,376 KB
testcase_08 AC 10 ms
4,380 KB
testcase_09 AC 163 ms
6,796 KB
testcase_10 AC 153 ms
6,520 KB
testcase_11 WA -
testcase_12 AC 158 ms
6,564 KB
testcase_13 AC 161 ms
6,500 KB
testcase_14 AC 153 ms
6,512 KB
testcase_15 AC 153 ms
6,564 KB
testcase_16 AC 155 ms
6,504 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 161 ms
6,504 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 151 ms
6,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#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;}

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

const ull INF = 4e18;

ull dp[MAX];
ull vs[MAX]={};

const int BS = 1000;
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]-a*i;

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

    cur+=as[i]+bs[i];

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

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