10451 | 2024-04-02 20:40:25 | 111 | Modern Art | cpp17 | Wrong answer 5/100 | 8ms | 5980 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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1696 KiB | ||||
2 | Accepted | 3ms | 1932 KiB | ||||
subtask2 | 5/5 | ||||||
3 | Accepted | 4ms | 2384 KiB | ||||
4 | Accepted | 4ms | 2436 KiB | ||||
5 | Accepted | 7ms | 3308 KiB | ||||
6 | Accepted | 8ms | 3932 KiB | ||||
7 | Accepted | 8ms | 4324 KiB | ||||
8 | Accepted | 8ms | 4020 KiB | ||||
9 | Accepted | 7ms | 3912 KiB | ||||
10 | Accepted | 3ms | 3076 KiB | ||||
subtask3 | 0/15 | ||||||
11 | Accepted | 2ms | 3012 KiB | ||||
12 | Accepted | 3ms | 3228 KiB | ||||
13 | Accepted | 2ms | 3220 KiB | ||||
14 | Wrong answer | 2ms | 3216 KiB | ||||
15 | Accepted | 2ms | 3224 KiB | ||||
16 | Wrong answer | 2ms | 3320 KiB | ||||
17 | Accepted | 2ms | 3316 KiB | ||||
18 | Accepted | 3ms | 3452 KiB | ||||
19 | Wrong answer | 3ms | 3588 KiB | ||||
subtask4 | 0/30 | ||||||
20 | Wrong answer | 3ms | 3616 KiB | ||||
21 | Wrong answer | 3ms | 3772 KiB | ||||
22 | Accepted | 3ms | 3792 KiB | ||||
23 | Wrong answer | 3ms | 3740 KiB | ||||
24 | Wrong answer | 3ms | 3848 KiB | ||||
25 | Accepted | 3ms | 4176 KiB | ||||
26 | Accepted | 3ms | 4084 KiB | ||||
27 | Accepted | 3ms | 4124 KiB | ||||
28 | Wrong answer | 3ms | 4144 KiB | ||||
subtask5 | 0/50 | ||||||
29 | Accepted | 3ms | 4200 KiB | ||||
30 | Wrong answer | 3ms | 4340 KiB | ||||
31 | Wrong answer | 4ms | 4384 KiB | ||||
32 | Wrong answer | 4ms | 4376 KiB | ||||
33 | Wrong answer | 4ms | 4384 KiB | ||||
34 | Accepted | 4ms | 4332 KiB | ||||
35 | Wrong answer | 7ms | 4748 KiB | ||||
36 | Wrong answer | 4ms | 4476 KiB | ||||
37 | Wrong answer | 7ms | 4480 KiB | ||||
38 | Wrong answer | 7ms | 4492 KiB | ||||
39 | Accepted | 3ms | 4304 KiB | ||||
40 | Accepted | 8ms | 5772 KiB | ||||
41 | Accepted | 8ms | 5980 KiB | ||||
42 | Wrong answer | 6ms | 4732 KiB | ||||
43 | Wrong answer | 6ms | 4500 KiB | ||||
44 | Wrong answer | 8ms | 4988 KiB | ||||
45 | Wrong answer | 8ms | 5368 KiB |