結果

問題 No.1297 銅像
ユーザー 沙耶花沙耶花
提出日時 2020-06-06 15:30:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 746 bytes
コンパイル時間 2,214 ms
コンパイル使用メモリ 203,472 KB
実行使用メモリ 11,480 KB
最終ジャッジ日時 2023-09-18 01:38:41
合計ジャッジ時間 6,179 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
11,480 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 54 ms
4,376 KB
testcase_07 AC 50 ms
4,376 KB
testcase_08 AC 53 ms
4,380 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 #

#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 2000000000000000000



int main(){
	
	int N;
	cin>>N;
	
	long long C;
	cin>>C;
	
	vector<long long> a(N),b(N);
	for(int i=0;i<N;i++)cin>>a[i]>>b[i];
	
	vector<vector<long long>> dp(N+1,vector<long long>(2,Inf));
	dp[0][1] = 0;
	
	for(int i=1;i<=N;i++){
		long long mini = Inf;
		long long t = 0;
		for(int j=i;j>=1;j--){
			t += C*abs(i-j)+a[i-1];
			dp[i][0] = min(dp[i][0],t+dp[j-1][1]);
		}
		dp[i][0] += b[i-1];
		t=0;
		dp[i][1] = dp[i][0];
		for(int j=i-1;j>=1;j--){
			t += C*abs(i-j);
			dp[i][1] = min(dp[i][1],t+dp[j][0]+a[j-1]*abs(i-j));
		}
	}
	
	cout<<dp.back().back()<<endl;
		
	
	return 0;
}
0