답안 #762932

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
762932 2023-06-22T01:29:40 Z vjudge1 Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
123 ms 7404 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[4*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(0,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(0,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();
	}
		
}

Compilation message

ho_t1.cpp:12:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   12 | const int inf = 1e18;
      |                 ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 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 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 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 1 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 Correct 111 ms 6764 KB Output is correct
34 Correct 112 ms 7000 KB Output is correct
35 Correct 104 ms 6812 KB Output is correct
36 Correct 106 ms 7324 KB Output is correct
37 Correct 123 ms 7404 KB Output is correct
38 Correct 108 ms 7372 KB Output is correct
39 Correct 105 ms 6572 KB Output is correct
40 Correct 115 ms 6432 KB Output is correct
41 Correct 107 ms 6604 KB Output is correct
42 Correct 106 ms 6588 KB Output is correct
43 Correct 103 ms 6480 KB Output is correct
44 Correct 101 ms 6140 KB Output is correct
45 Correct 104 ms 6224 KB Output is correct
46 Correct 103 ms 6136 KB Output is correct
47 Correct 102 ms 5968 KB Output is correct
48 Correct 101 ms 6004 KB Output is correct
49 Correct 112 ms 6588 KB Output is correct
50 Correct 111 ms 6604 KB Output is correct
51 Correct 110 ms 6648 KB Output is correct
52 Correct 107 ms 6628 KB Output is correct
53 Correct 107 ms 6652 KB Output is correct