답안 #504084

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
504084 2022-01-09T17:29:10 Z lucri Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
233 ms 10720 KB
#include <iostream>
#include <algorithm>
using namespace std;
int n,b[200010],r[200010];
struct cravata{int val,poz;}a[200010],dif[200010];
bool comp1(cravata a,cravata b)
{
    return a.val<b.val;
}
int main()
{
    cin>>n;
    for(int i=1;i<=n+1;++i)
    {
        cin>>a[i].val;
        a[i].poz=i;
    }
    for(int i=1;i<=n;++i)
        cin>>b[i];
    sort(a+1,a+n+2,comp1);
    sort(b+1,b+n+1);
    for(int i=1;i<=n;++i)
    {
        dif[i].poz=i;
        dif[i].val=max(0,a[i].val-b[i]);
    }
    sort(dif+1,dif+n+1,comp1);
    r[a[n+1].poz]=dif[n].val;
    int maxa=0,poza=n;
    for(int i=n;i>=1;--i)
    {
        maxa=max(maxa,a[i+1].val-b[i]);
        while(dif[poza].val>maxa&&dif[poza].poz>=i)
            --poza;
        r[a[i].poz]=max(maxa,dif[poza].val);
    }
    for(int i=1;i<=n+1;++i)
        cout<<r[i]<<' ';
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 292 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 300 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 280 KB Output is correct
10 Correct 1 ms 280 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 292 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 300 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 280 KB Output is correct
10 Correct 1 ms 280 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 2 ms 304 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 4 ms 348 KB Output is correct
20 Correct 4 ms 308 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 2 ms 328 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 2 ms 328 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 2 ms 332 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 2 ms 288 KB Output is correct
30 Correct 3 ms 332 KB Output is correct
31 Correct 2 ms 312 KB Output is correct
32 Correct 4 ms 308 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 292 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 300 KB Output is correct
4 Correct 1 ms 300 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 280 KB Output is correct
10 Correct 1 ms 280 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 2 ms 304 KB Output is correct
18 Correct 2 ms 332 KB Output is correct
19 Correct 4 ms 348 KB Output is correct
20 Correct 4 ms 308 KB Output is correct
21 Correct 2 ms 332 KB Output is correct
22 Correct 3 ms 340 KB Output is correct
23 Correct 2 ms 328 KB Output is correct
24 Correct 2 ms 332 KB Output is correct
25 Correct 2 ms 328 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 2 ms 332 KB Output is correct
28 Correct 2 ms 332 KB Output is correct
29 Correct 2 ms 288 KB Output is correct
30 Correct 3 ms 332 KB Output is correct
31 Correct 2 ms 312 KB Output is correct
32 Correct 4 ms 308 KB Output is correct
33 Correct 199 ms 9876 KB Output is correct
34 Correct 219 ms 10292 KB Output is correct
35 Correct 208 ms 9952 KB Output is correct
36 Correct 218 ms 10424 KB Output is correct
37 Correct 226 ms 10704 KB Output is correct
38 Correct 220 ms 10720 KB Output is correct
39 Correct 191 ms 9668 KB Output is correct
40 Correct 233 ms 9628 KB Output is correct
41 Correct 226 ms 9804 KB Output is correct
42 Correct 199 ms 9796 KB Output is correct
43 Correct 197 ms 9728 KB Output is correct
44 Correct 197 ms 9256 KB Output is correct
45 Correct 205 ms 9320 KB Output is correct
46 Correct 216 ms 9220 KB Output is correct
47 Correct 191 ms 9488 KB Output is correct
48 Correct 176 ms 9372 KB Output is correct
49 Correct 215 ms 9952 KB Output is correct
50 Correct 229 ms 9924 KB Output is correct
51 Correct 203 ms 9896 KB Output is correct
52 Correct 212 ms 9900 KB Output is correct
53 Correct 205 ms 9952 KB Output is correct