Submission #856991

# Submission time Handle Problem Language Result Execution time Memory
856991 2023-10-05T07:26:07 Z StefanSebez Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
214 ms 12364 KB
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define int long long
signed main()
{
    int n;cin>>n;
    pair<int,int> a[n+50];for(int i=1;i<=n+1;i++){cin>>a[i].fi;a[i].se=i;}
    int b[n+50];
    for(int i=1;i<=n;i++)cin>>b[i];
    sort(a+1,a+n+2);
    sort(b+1,b+n+1);
    int res[n+50]={0},sum=0;
    for(int i=1;i<=n;i++)
	{
		sum=max(sum,max(a[i].fi-b[i],(int)0));
	}
	res[a[n+1].se]=sum;
    for(int i=n;i>=1;i--)
	{
		//sum-=max(a[i].fi-b[i],0);
		sum=max(sum,max(a[i+1].fi-b[i],(int)0));
		res[a[i].se]=sum;
	}
	for(int i=1;i<=n+1;i++) cout<<res[i]<<" ";
	cout<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 424 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 436 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 444 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 424 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 436 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 444 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 440 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
20 Correct 2 ms 708 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 2 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 424 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 436 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 444 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 468 KB Output is correct
15 Correct 1 ms 604 KB Output is correct
16 Correct 1 ms 440 KB Output is correct
17 Correct 2 ms 348 KB Output is correct
18 Correct 1 ms 604 KB Output is correct
19 Correct 2 ms 344 KB Output is correct
20 Correct 2 ms 708 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 2 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 151 ms 11344 KB Output is correct
34 Correct 148 ms 11860 KB Output is correct
35 Correct 145 ms 11604 KB Output is correct
36 Correct 144 ms 12092 KB Output is correct
37 Correct 173 ms 12364 KB Output is correct
38 Correct 214 ms 12180 KB Output is correct
39 Correct 144 ms 11240 KB Output is correct
40 Correct 176 ms 11248 KB Output is correct
41 Correct 196 ms 11400 KB Output is correct
42 Correct 160 ms 11300 KB Output is correct
43 Correct 153 ms 11256 KB Output is correct
44 Correct 154 ms 10792 KB Output is correct
45 Correct 187 ms 10944 KB Output is correct
46 Correct 154 ms 10832 KB Output is correct
47 Correct 173 ms 11088 KB Output is correct
48 Correct 147 ms 11052 KB Output is correct
49 Correct 157 ms 11716 KB Output is correct
50 Correct 211 ms 11600 KB Output is correct
51 Correct 153 ms 11752 KB Output is correct
52 Correct 162 ms 11604 KB Output is correct
53 Correct 158 ms 11468 KB Output is correct