답안 #870607

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
870607 2023-11-08T13:18:22 Z Maite_Morale Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
190 ms 24740 KB
#include<bits/stdc++.h>
#define F first
#define S second
#define MAX 500005
#define oo 1e18
#define mod 1000000007
#define fast_in ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout.setf(ios::fixed);cout.precision(0);
using namespace std;
typedef long long ll;
#define pll pair<ll , ll>
#define vll vector<ll>
#define vvll vector<vll>
#define vpll vector<pll>

ll n,t[MAX],a[MAX];
pll b[MAX],r[MAX];
int main(){
    cin>>n;
    for(int i=0;i<=n;i++){
        cin>>b[i].F;b[i].S=i;
    }
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);sort(b,b+(n+1));
    t[n-1]=max((ll)0,b[n].F-a[n-1]);
    for(int i=n-2;i>=0;i--){
        t[i]=max(t[i+1],max((ll)0,b[i+1].F-a[i]));
    }ll s=0;
    for(int i=0;i<n;i++){
        r[i].S=max(s,t[i]);r[i].F=b[i].S;
        s=max(s,max((ll)0,b[i].F-a[i]));
    }r[n].S=s;r[n].F=b[n].S;
    sort(r,r+(n+1));
    for(int i=0;i<=n;i++)cout<<r[i].S<<" ";

return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6592 KB Output is correct
6 Correct 1 ms 6744 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6488 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6592 KB Output is correct
6 Correct 1 ms 6744 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6488 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6488 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6600 KB Output is correct
16 Correct 1 ms 6488 KB Output is correct
17 Correct 2 ms 6492 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 3 ms 6748 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 3 ms 6492 KB Output is correct
22 Correct 3 ms 6492 KB Output is correct
23 Correct 3 ms 6492 KB Output is correct
24 Correct 3 ms 6492 KB Output is correct
25 Correct 2 ms 6628 KB Output is correct
26 Correct 2 ms 6744 KB Output is correct
27 Correct 2 ms 6492 KB Output is correct
28 Correct 2 ms 6744 KB Output is correct
29 Correct 2 ms 6492 KB Output is correct
30 Correct 2 ms 6492 KB Output is correct
31 Correct 2 ms 6488 KB Output is correct
32 Correct 3 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6592 KB Output is correct
6 Correct 1 ms 6744 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6488 KB Output is correct
11 Correct 1 ms 6492 KB Output is correct
12 Correct 1 ms 6492 KB Output is correct
13 Correct 1 ms 6488 KB Output is correct
14 Correct 2 ms 6492 KB Output is correct
15 Correct 2 ms 6600 KB Output is correct
16 Correct 1 ms 6488 KB Output is correct
17 Correct 2 ms 6492 KB Output is correct
18 Correct 2 ms 6492 KB Output is correct
19 Correct 3 ms 6748 KB Output is correct
20 Correct 2 ms 6492 KB Output is correct
21 Correct 3 ms 6492 KB Output is correct
22 Correct 3 ms 6492 KB Output is correct
23 Correct 3 ms 6492 KB Output is correct
24 Correct 3 ms 6492 KB Output is correct
25 Correct 2 ms 6628 KB Output is correct
26 Correct 2 ms 6744 KB Output is correct
27 Correct 2 ms 6492 KB Output is correct
28 Correct 2 ms 6744 KB Output is correct
29 Correct 2 ms 6492 KB Output is correct
30 Correct 2 ms 6492 KB Output is correct
31 Correct 2 ms 6488 KB Output is correct
32 Correct 3 ms 6492 KB Output is correct
33 Correct 154 ms 24228 KB Output is correct
34 Correct 162 ms 24356 KB Output is correct
35 Correct 168 ms 24148 KB Output is correct
36 Correct 167 ms 24740 KB Output is correct
37 Correct 162 ms 24712 KB Output is correct
38 Correct 165 ms 24620 KB Output is correct
39 Correct 158 ms 23892 KB Output is correct
40 Correct 156 ms 23892 KB Output is correct
41 Correct 161 ms 23892 KB Output is correct
42 Correct 165 ms 23892 KB Output is correct
43 Correct 158 ms 23892 KB Output is correct
44 Correct 155 ms 23588 KB Output is correct
45 Correct 157 ms 23636 KB Output is correct
46 Correct 153 ms 23576 KB Output is correct
47 Correct 151 ms 23660 KB Output is correct
48 Correct 156 ms 23448 KB Output is correct
49 Correct 161 ms 23888 KB Output is correct
50 Correct 165 ms 23964 KB Output is correct
51 Correct 158 ms 23972 KB Output is correct
52 Correct 162 ms 24100 KB Output is correct
53 Correct 190 ms 24080 KB Output is correct