11033 | 2024-06-28 11:01:05 | BaranJ | Modern Art | cpp17 | Wrong answer 0/100 | 17ms | 1528 KiB |
#include<bits/stdc++.h>
using namespace std;
int main(){
int n; cin>>n;
vector<pair<long long, int>> t(2*n);
vector<int> x(n);
for(int i=0; i<n; i++){
cin>>x[i];
}
for(int i=0; i<n; i++){
int r; cin>>r;
t[2*i]={x[i]-r, 2*r};
t[2*i+1]={x[i]+r, -2*r};
}
sort(t.begin(), t.end());
long long unio=0, most=0, previ=0;
map<int, int> m;
m[0]=1;
for(int i=0; i<2*n; i++){
unio+=most*(t[i].first-previ);
//cout<<most<<" "<<t[i].first<<" "<<previ<<" "<<most*(t[i].first-previ)<<endl;
previ=t[i].first;
while(true){
if(t[i].second > 0){m[-t[i].second]++;}
else{
m[t[i].second]--;
if(m[t[i].second]==0){
m.erase(t[i].second);
}
}
if(i >=2*n-1 || t[i].first!=t[i+1].first){break;}
i++;
}
/*for (auto itr = m.begin(); itr != m.end(); ++itr) {
cout << itr->first
<< '\t' << itr->second << '\n';
}*/
most=-m.begin()->first;
//cout<<most<<" ";
}
cout<<endl<<unio;
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 2ms | 356 KiB | ||||
2 | Wrong answer | 2ms | 356 KiB | ||||
subtask2 | 0/5 | ||||||
3 | Wrong answer | 6ms | 872 KiB | ||||
4 | Wrong answer | 8ms | 780 KiB | ||||
5 | Wrong answer | 8ms | 656 KiB | ||||
6 | Wrong answer | 10ms | 892 KiB | ||||
7 | Wrong answer | 12ms | 840 KiB | ||||
8 | Wrong answer | 9ms | 756 KiB | ||||
9 | Wrong answer | 9ms | 740 KiB | ||||
10 | Wrong answer | 3ms | 504 KiB | ||||
subtask3 | 0/15 | ||||||
11 | Wrong answer | 3ms | 508 KiB | ||||
12 | Wrong answer | 3ms | 356 KiB | ||||
13 | Wrong answer | 3ms | 504 KiB | ||||
14 | Wrong answer | 3ms | 384 KiB | ||||
15 | Wrong answer | 3ms | 356 KiB | ||||
16 | Wrong answer | 2ms | 496 KiB | ||||
17 | Wrong answer | 3ms | 516 KiB | ||||
18 | Wrong answer | 3ms | 504 KiB | ||||
19 | Wrong answer | 3ms | 504 KiB | ||||
subtask4 | 0/30 | ||||||
20 | Wrong answer | 3ms | 356 KiB | ||||
21 | Wrong answer | 3ms | 484 KiB | ||||
22 | Wrong answer | 3ms | 356 KiB | ||||
23 | Wrong answer | 4ms | 484 KiB | ||||
24 | Wrong answer | 3ms | 428 KiB | ||||
25 | Wrong answer | 3ms | 356 KiB | ||||
26 | Wrong answer | 3ms | 496 KiB | ||||
27 | Wrong answer | 3ms | 620 KiB | ||||
28 | Wrong answer | 3ms | 356 KiB | ||||
subtask5 | 0/50 | ||||||
29 | Wrong answer | 3ms | 572 KiB | ||||
30 | Wrong answer | 4ms | 356 KiB | ||||
31 | Wrong answer | 6ms | 572 KiB | ||||
32 | Wrong answer | 12ms | 912 KiB | ||||
33 | Wrong answer | 12ms | 760 KiB | ||||
34 | Wrong answer | 7ms | 668 KiB | ||||
35 | Wrong answer | 13ms | 1016 KiB | ||||
36 | Wrong answer | 4ms | 504 KiB | ||||
37 | Wrong answer | 14ms | 892 KiB | ||||
38 | Wrong answer | 14ms | 868 KiB | ||||
39 | Wrong answer | 3ms | 356 KiB | ||||
40 | Wrong answer | 14ms | 1188 KiB | ||||
41 | Wrong answer | 14ms | 1256 KiB | ||||
42 | Wrong answer | 14ms | 1380 KiB | ||||
43 | Wrong answer | 14ms | 1320 KiB | ||||
44 | Wrong answer | 17ms | 1404 KiB | ||||
45 | Wrong answer | 17ms | 1528 KiB |