#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define setbits(x) __builtin_popcountll(x)
#define ff first
#define ss second
#define conts continue
#define ceil2(x,y) ((x+y-1)/(y))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define rev(i,s,e) for(int i = s; i >= e; --i)
#define trav(i,a) for(auto &i : a)
template<typename T>
void amin(T &a, T b) {
a = min(a,b);
}
template<typename T>
void amax(T &a, T b) {
a = max(a,b);
}
#ifdef LOCAL
#include "debug.h"
#else
#define debug(x) 42
#endif
/*
*/
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;
const int inf1 = int(1e9) + 5;
const ll inf2 = ll(1e18) + 5;
template<typename T>
struct lazysegtree {
/*=======================================================*/
struct data {
ll mn,mx,res,active;
};
struct lazy {
ll a;
};
data d_neutral = {inf2,-inf2,0,0};
lazy l_neutral = {0};
void merge(data &curr, data &left, data &right) {
curr.mn = min(left.mn,right.mn);
curr.mx = max(left.mx,right.mx);
curr.res = max({left.res,right.res,left.mx-right.mn});
curr.active = left.active+right.active;
}
void create(int x, int lx, int rx, T v) {
}
void modify(int x, int lx, int rx, T v) {
if(v.ff == 1){
lz[x].a = v.ss;
}
else{
tr[x].mn = tr[x].mx = v.ss;
tr[x].res = 0;
tr[x].active = 1;
}
}
void propagate(int x, int lx, int rx) {
ll v = lz[x].a;
if(!v) return;
tr[x].mn += v;
tr[x].mx += v;
if(rx-lx > 1){
lz[2*x+1].a += v;
lz[2*x+2].a += v;
}
lz[x] = l_neutral;
}
/*=======================================================*/
int siz = 1;
vector<data> tr;
vector<lazy> lz;
lazysegtree() {
}
lazysegtree(int n) {
while (siz < n) siz *= 2;
tr.assign(2 * siz, d_neutral);
lz.assign(2 * siz, l_neutral);
}
void build(vector<T> &a, int n, int x, int lx, int rx) {
if (rx - lx == 1) {
if (lx < n) {
create(x, lx, rx, a[lx]);
}
return;
}
int mid = (lx + rx) / 2;
build(a, n, 2 * x + 1, lx, mid);
build(a, n, 2 * x + 2, mid, rx);
merge(tr[x], tr[2 * x + 1], tr[2 * x + 2]);
}
void build(vector<T> &a, int n) {
build(a, n, 0, 0, siz);
}
void rupd(int l, int r, T v, int x, int lx, int rx) {
propagate(x, lx, rx);
if (lx >= r or rx <= l) return;
if (lx >= l and rx <= r) {
modify(x, lx, rx, v);
propagate(x, lx, rx);
return;
}
int mid = (lx + rx) / 2;
rupd(l, r, v, 2 * x + 1, lx, mid);
rupd(l, r, v, 2 * x + 2, mid, rx);
merge(tr[x], tr[2 * x + 1], tr[2 * x + 2]);
}
void rupd(int l, int r, T v) {
rupd(l, r + 1, v, 0, 0, siz);
}
data query(int l, int r, int x, int lx, int rx) {
propagate(x, lx, rx);
if (lx >= r or rx <= l) return d_neutral;
if (lx >= l and rx <= r) return tr[x];
int mid = (lx + rx) / 2;
data curr;
data left = query(l, r, 2 * x + 1, lx, mid);
data right = query(l, r, 2 * x + 2, mid, rx);
merge(curr, left, right);
return curr;
}
data query(int l, int r) {
return query(l, r + 1, 0, 0, siz);
}
};
void solve(int test_case)
{
ll n,m,d; cin >> n >> m >> d;
d *= 2;
vector<ll> a(n+5), b(m+5);
rep1(i,n) cin >> a[i], a[i] *= 2;
rep1(i,m) cin >> b[i], b[i] *= 2;
vector<ll> c;
rep1(i,n) c.pb(a[i]);
rep1(i,m) c.pb(b[i]);
c.pb(0);
sort(all(c));
ll siz = sz(c)-1;
map<ll,ll> mp;
rep1(i,siz){
if(c[i] != c[i-1]){
mp[c[i]] = i;
}
}
lazysegtree<pll> st(siz+5);
auto upd = [&](ll x){
ll i = mp[x]++;
st.rupd(i+1,siz,{1,-d});
ll active = st.query(1,i-1).active;
st.rupd(i,i,{2,x-d*(active+1)});
};
rep1(i,m){
ll x = b[i];
upd(x);
ll ans = st.query(1,siz).res;
ans /= 2;
cout << ans/2;
if(ans&1) cout << ".5";
cout << " ";
}
cout << endl;
}
int main()
{
fastio;
int t = 1;
// cin >> t;
rep1(i, t) {
solve(i);
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
412 ms |
37524 KB |
Output is correct |
2 |
Correct |
424 ms |
39648 KB |
Output is correct |
3 |
Correct |
343 ms |
27156 KB |
Output is correct |
4 |
Correct |
416 ms |
37188 KB |
Output is correct |
5 |
Correct |
427 ms |
39120 KB |
Output is correct |
6 |
Correct |
417 ms |
37576 KB |
Output is correct |
7 |
Correct |
431 ms |
38892 KB |
Output is correct |
8 |
Correct |
413 ms |
37324 KB |
Output is correct |
9 |
Correct |
416 ms |
37324 KB |
Output is correct |
10 |
Correct |
417 ms |
39884 KB |
Output is correct |
11 |
Correct |
413 ms |
38092 KB |
Output is correct |
12 |
Correct |
419 ms |
39680 KB |
Output is correct |
13 |
Correct |
415 ms |
37380 KB |
Output is correct |
14 |
Correct |
414 ms |
39164 KB |
Output is correct |
15 |
Correct |
426 ms |
39676 KB |
Output is correct |
16 |
Correct |
414 ms |
37320 KB |
Output is correct |
17 |
Correct |
426 ms |
38732 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
412 ms |
37524 KB |
Output is correct |
2 |
Correct |
424 ms |
39648 KB |
Output is correct |
3 |
Correct |
343 ms |
27156 KB |
Output is correct |
4 |
Correct |
416 ms |
37188 KB |
Output is correct |
5 |
Correct |
427 ms |
39120 KB |
Output is correct |
6 |
Correct |
417 ms |
37576 KB |
Output is correct |
7 |
Correct |
431 ms |
38892 KB |
Output is correct |
8 |
Correct |
413 ms |
37324 KB |
Output is correct |
9 |
Correct |
416 ms |
37324 KB |
Output is correct |
10 |
Correct |
417 ms |
39884 KB |
Output is correct |
11 |
Correct |
413 ms |
38092 KB |
Output is correct |
12 |
Correct |
419 ms |
39680 KB |
Output is correct |
13 |
Correct |
415 ms |
37380 KB |
Output is correct |
14 |
Correct |
414 ms |
39164 KB |
Output is correct |
15 |
Correct |
426 ms |
39676 KB |
Output is correct |
16 |
Correct |
414 ms |
37320 KB |
Output is correct |
17 |
Correct |
426 ms |
38732 KB |
Output is correct |
18 |
Correct |
609 ms |
38200 KB |
Output is correct |
19 |
Correct |
599 ms |
41420 KB |
Output is correct |
20 |
Correct |
350 ms |
28892 KB |
Output is correct |
21 |
Correct |
451 ms |
39720 KB |
Output is correct |
22 |
Correct |
515 ms |
39708 KB |
Output is correct |
23 |
Correct |
424 ms |
39624 KB |
Output is correct |
24 |
Correct |
638 ms |
40144 KB |
Output is correct |
25 |
Correct |
420 ms |
39324 KB |
Output is correct |
26 |
Correct |
585 ms |
39112 KB |
Output is correct |
27 |
Correct |
613 ms |
42288 KB |
Output is correct |
28 |
Correct |
539 ms |
39880 KB |
Output is correct |
29 |
Correct |
542 ms |
40904 KB |
Output is correct |
30 |
Correct |
439 ms |
39264 KB |
Output is correct |
31 |
Correct |
455 ms |
41168 KB |
Output is correct |
32 |
Correct |
429 ms |
40904 KB |
Output is correct |
33 |
Correct |
593 ms |
39368 KB |
Output is correct |
34 |
Correct |
443 ms |
40648 KB |
Output is correct |