結果
問題 | No.1297 銅像 |
ユーザー |
![]() |
提出日時 | 2020-11-20 22:51:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 905 bytes |
コンパイル時間 | 4,884 ms |
コンパイル使用メモリ | 223,424 KB |
最終ジャッジ日時 | 2025-01-16 02:56:16 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 4 WA * 3 TLE * 14 |
ソースコード
#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 HEREusing ull = long long;const int MAX = 1e5+10;ull as[MAX];ull bs[MAX];const ull INF = 4e18;ull dp[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);dp[0]=0;for(int i=0;i<n;i++){ull a=as[i];ull cur=dp[i]-a*i;for(int p=0;p<i;p++)chmin(cur,dp[p]-a*p+(i*(i+1)/2+p*(p-1)/2-i*p)*c);cur+=as[i]+bs[i];// [-, j]for(int j=i;j<n;j++)chmin(dp[j+1],cur+a*j+(j*(j+1)/2+i*(i-1)/2-j*i)*c);}cout<<dp[n]<<endl;return 0;}