Submission #762911

# Submission time Handle Problem Language Result Execution time Memory
762911 2023-06-22T01:19:31 Z vjudge1 Just Long Neckties (JOI20_ho_t1) C++17
9 / 100
91 ms 9428 KB
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
#define int long long
//#define ld long double
using namespace std;
using ll=long long;
const int inf = 1e18;
const int MN =200005;
const int mod=1e9+7;
int n;
pii a[MN];
int b[MN];
int ans[MN];
int st[MN];
void update(int id, int l, int r, int pos, int val) {
	if(l==r) {
		st[id]=val;
		return;
	}
	int m=(l+r)/2;
	if(pos<=m) update(id*2,l,m,pos,val);	
	else update(id*2+1,m+1,r,pos,val);
	st[id]=max(st[id*2],st[id*2+1]);
}
int get(int id, int l, int r, int tl, int tr) {
	if(tl>r||tr<l) return -inf;
	if(tl<=l&&tr>=r) return st[id];
	int m=(l+r)/2;
	return max(get(id*2,l,m,tl,tr), get(id*2+1,m+1,r,tl,tr));
}
void solve() {
	cin>>n;
	for (int i=1; i<=n+1; i++) {
		cin>>a[i].fi;
		a[i].se=i;
	}
	for (int i=1; i<=n; i++) {
		cin>>b[i];
	}
	sort(b+1,b+n+1);
	sort(a+1,a+n+2);
	for (int i=1; i<=n; i++) {
		update(1,1,n,i,max(0ll,a[i+1].fi-b[i]));
		ans[a[1].se]=st[1];
	}
	for (int i=2; i<=n+1; i++) {
		update(1,1,n,i-1, max(0ll,a[i-1].fi-b[i-1]));
		ans[a[i].se]=st[1];
	}
	for (int i=1; i<=n+1; i++) {
		cout<<ans[i]<<" ";
	}
}
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
//	freopen(".inp", "r", stdin);
//	freopen(".out", "w", stdout);
	int t=1;
//	cin>>t;
	while(t--) {
		solve();
	}
		
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 240 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 240 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 240 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Incorrect 91 ms 9428 KB Output isn't correct
34 Halted 0 ms 0 KB -