結果
問題 |
No.1297 銅像
|
ユーザー |
![]() |
提出日時 | 2020-11-20 22:25:43 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 785 bytes |
コンパイル時間 | 3,231 ms |
コンパイル使用メモリ | 220,600 KB |
最終ジャッジ日時 | 2025-01-16 02:37:23 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 7 TLE * 14 |
ソースコード
#pragma GCC optimize ("O3") #pragma GCC target ("avx2") // or sse4 #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; //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++) cur=min(cur,dp[p]+a*(i-p)+vs[i-p]); cur+=bs[i]; // [-, j] for(int j=i;j<n;j++) dp[j+1]=min(dp[j+1],cur+a*(j-i+1)+vs[j-i]); } cout<<dp[n]<<endl; return 0; }