#include <bits/stdc++.h>
#define speed ios_base::sync_with_stdio(0); cin.tie(0)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MAX=1e5+10,P=998244353;
const ll INF=0x3f3f3f3f,oo=0x3f3f3f3f3f3f3f3f;
ll n,q;
ll pos[MAX];
pll dis[MAX];
pll rg[MAX];
int main() {
speed;
cin>>n>>q;
for (int i=0;i<n;i++) {
cin>>pos[i];
rg[i]={-1,-1};
if (i!=0) dis[i-1]={pos[i]-pos[i-1],i-1};
}
sort(dis,dis+n-1);
ll L=0,R=0;
ll now=0;
ll id=0;
while (q--) {
ll k;
cin>>k;
now+=k;
if (now>R) {
R=now;
while (id<n-1 and dis[id].first<R-L) {
// cout<<dis[id].first<<" "<<dis[id].second<<" id\n";
rg[dis[id].second].second=pos[dis[id].second+1]+L;
rg[dis[id].second+1].first=pos[dis[id].second+1]+L;
id++;
}
} else if (now<L) {
L=now;
while (id<n-1 and dis[id].first<R-L) {
rg[dis[id].second+1].first=pos[dis[id].second]+R;
rg[dis[id].second].second=pos[dis[id].second]+R;
id++;
}
}
// cout<<L<<" "<<R<<"\n";
}
for (int i=0;i<n;i++) {
// cout<<rg[i].first<<" "<<rg[i].second<<"\n";
if (rg[i].first==-1) rg[i].first=pos[i]+L;
if (rg[i].second==-1) rg[i].second=pos[i]+R;
cout<<rg[i].second-rg[i].first<<"\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2592 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2520 KB |
Output is correct |
7 |
Correct |
2 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
2 ms |
2392 KB |
Output is correct |
16 |
Correct |
2 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
0 ms |
472 KB |
Output is correct |
19 |
Correct |
2 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2648 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2592 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2520 KB |
Output is correct |
7 |
Correct |
2 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2396 KB |
Output is correct |
10 |
Correct |
1 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
2 ms |
2392 KB |
Output is correct |
16 |
Correct |
2 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
0 ms |
472 KB |
Output is correct |
19 |
Correct |
2 ms |
2392 KB |
Output is correct |
20 |
Correct |
20 ms |
4424 KB |
Output is correct |
21 |
Correct |
18 ms |
4444 KB |
Output is correct |
22 |
Correct |
17 ms |
4040 KB |
Output is correct |
23 |
Correct |
15 ms |
4148 KB |
Output is correct |
24 |
Correct |
19 ms |
4444 KB |
Output is correct |
25 |
Runtime error |
14 ms |
9820 KB |
Execution killed with signal 11 |
26 |
Halted |
0 ms |
0 KB |
- |