104512024-04-02 20:40:25111Modern Artcpp17Wrong answer 5/1008ms5980 KiB
#include<bits/stdc++.h>
using namespace std;

#define int long long

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin>>N;
	vector<pair<int,int>>v(N);
	for(int i=0;i<N;i++){
		cin>>v[i].second;
	}
	for(int i=0;i<N;i++){
		cin>>v[i].first;
	}
	sort(v.rbegin(),v.rend());
	int ans=0;
	set<pair<int,int>>c;
	for(auto[r,x]:v){
		int s=x-r,e=x+r;
		auto t=c.lower_bound({x-r,INT_MIN});
		if(t!=c.end()){
			e=min(e,t->first);
		}
		if(t!=c.begin()){
			s=max(s,prev(t)->second);
		}
		if(e>s){
			ans+=(e-s)*r*2;
			c.emplace(s,e);
		}
	}
	cout<<ans<<'\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms1696 KiB
2Accepted3ms1932 KiB
subtask25/5
3Accepted4ms2384 KiB
4Accepted4ms2436 KiB
5Accepted7ms3308 KiB
6Accepted8ms3932 KiB
7Accepted8ms4324 KiB
8Accepted8ms4020 KiB
9Accepted7ms3912 KiB
10Accepted3ms3076 KiB
subtask30/15
11Accepted2ms3012 KiB
12Accepted3ms3228 KiB
13Accepted2ms3220 KiB
14Wrong answer2ms3216 KiB
15Accepted2ms3224 KiB
16Wrong answer2ms3320 KiB
17Accepted2ms3316 KiB
18Accepted3ms3452 KiB
19Wrong answer3ms3588 KiB
subtask40/30
20Wrong answer3ms3616 KiB
21Wrong answer3ms3772 KiB
22Accepted3ms3792 KiB
23Wrong answer3ms3740 KiB
24Wrong answer3ms3848 KiB
25Accepted3ms4176 KiB
26Accepted3ms4084 KiB
27Accepted3ms4124 KiB
28Wrong answer3ms4144 KiB
subtask50/50
29Accepted3ms4200 KiB
30Wrong answer3ms4340 KiB
31Wrong answer4ms4384 KiB
32Wrong answer4ms4376 KiB
33Wrong answer4ms4384 KiB
34Accepted4ms4332 KiB
35Wrong answer7ms4748 KiB
36Wrong answer4ms4476 KiB
37Wrong answer7ms4480 KiB
38Wrong answer7ms4492 KiB
39Accepted3ms4304 KiB
40Accepted8ms5772 KiB
41Accepted8ms5980 KiB
42Wrong answer6ms4732 KiB
43Wrong answer6ms4500 KiB
44Wrong answer8ms4988 KiB
45Wrong answer8ms5368 KiB