結果

問題 No.2566 美しい整数列
ユーザー 沙耶花沙耶花
提出日時 2023-12-06 01:14:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 340 ms / 2,000 ms
コード長 741 bytes
コンパイル時間 6,529 ms
コンパイル使用メモリ 269,264 KB
実行使用メモリ 21,280 KB
最終ジャッジ日時 2023-12-06 01:14:36
合計ジャッジ時間 13,370 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 340 ms
21,280 KB
testcase_05 AC 336 ms
21,280 KB
testcase_06 AC 207 ms
9,344 KB
testcase_07 AC 214 ms
9,344 KB
testcase_08 AC 210 ms
9,344 KB
testcase_09 AC 218 ms
9,344 KB
testcase_10 AC 214 ms
9,344 KB
testcase_11 AC 239 ms
12,388 KB
testcase_12 AC 241 ms
12,388 KB
testcase_13 AC 239 ms
12,388 KB
testcase_14 AC 246 ms
12,388 KB
testcase_15 AC 242 ms
12,388 KB
testcase_16 AC 270 ms
20,512 KB
testcase_17 AC 290 ms
20,488 KB
testcase_18 AC 320 ms
20,488 KB
testcase_19 AC 200 ms
14,856 KB
testcase_20 AC 262 ms
19,404 KB
testcase_21 AC 284 ms
19,692 KB
testcase_22 AC 185 ms
13,876 KB
testcase_23 AC 234 ms
18,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001

int main(){
	
	int N,M;
	cin>>N>>M;
	vector<long long> a(N),b(M);
	rep(i,N)cin>>a[i];
	rep(i,M)cin>>b[i];
	rep(i,b.size()){
		if(b.size()==N-1)break;
		b.push_back(b[i]);
	}
	vector<long long> c(N);
	rep(i,N)cin>>c[i];
	
	b.insert(b.begin(),0LL);
	rep(i,b.size()-1){
		b[i+1] += b[i];
	}
	map<long long,long long> mp;
	long long sum = 0;
	rep(i,N){
		mp[b[i]-a[i]] += c[i];
		sum += c[i];
	}
	long long ans = sum;
	for(auto x:mp)ans = min(ans,sum - x.second);
	cout<<ans<<endl;
	return 0;
}
0