Submission #762956

# Submission time Handle Problem Language Result Execution time Memory
762956 2023-06-22T01:45:37 Z vjudge1 Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
85 ms 10060 KB
#include<bits/stdc++.h>

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define gcd __gcd
#define endl '\n'
const int N=200050,M=1000000007;
const ll INF=0x3f3f3f3f3f3f3f3f;

pii a[N];
ll n, b[N], res[N], ans[N];

signed main(){
	ios_base::sync_with_stdio(NULL); 
	cin.tie(nullptr); cout.tie(nullptr);
	cin>>n;
	for(ll i=0; i<=n; ++i){
		cin>>a[i].fi;
		a[i].se=i;
	}
	for(ll i=0; i<n; ++i) cin>>b[i];
	sort(a, a+n+1);
	sort(b, b+n);
	for(ll i=0; i<n; ++i)
		res[i+1]=max(res[i], max(0LL, a[i].fi-b[i]));
	
	// for(ll i=0; i<=n; ++i) cout<<res[i]<<" ";
	// cout<<endl;
	for(ll i=n; i; --i)
		res[i-1]=max(res[i], max(0LL, a[i].fi-b[i-1]));
	for(ll i=0; i<=n; ++i) ans[a[i].se]=res[i];
	for(ll i=0; i<=n; ++i) cout<<ans[i]<<" ";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 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 0 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 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 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 0 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 1 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 424 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
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 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 0 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 1 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 424 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 66 ms 9288 KB Output is correct
34 Correct 70 ms 9568 KB Output is correct
35 Correct 72 ms 9300 KB Output is correct
36 Correct 67 ms 9768 KB Output is correct
37 Correct 70 ms 10060 KB Output is correct
38 Correct 72 ms 9936 KB Output is correct
39 Correct 67 ms 9036 KB Output is correct
40 Correct 67 ms 8976 KB Output is correct
41 Correct 81 ms 9164 KB Output is correct
42 Correct 68 ms 8988 KB Output is correct
43 Correct 71 ms 9052 KB Output is correct
44 Correct 70 ms 8632 KB Output is correct
45 Correct 66 ms 8676 KB Output is correct
46 Correct 67 ms 8652 KB Output is correct
47 Correct 63 ms 8652 KB Output is correct
48 Correct 63 ms 8588 KB Output is correct
49 Correct 69 ms 9296 KB Output is correct
50 Correct 70 ms 9232 KB Output is correct
51 Correct 69 ms 9292 KB Output is correct
52 Correct 69 ms 9228 KB Output is correct
53 Correct 85 ms 9304 KB Output is correct