답안 #201033

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
201033 2020-02-09T06:37:36 Z HellAngel Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
193 ms 7544 KB
#include <bits/stdc++.h>
using namespace std;

const int maxn = 200007;

int n, b[maxn], IT[4 * maxn], ans[maxn];
pair<int, int> a[maxn];

void Update(int id, int l, int r, int pos, int val)
{
    if(l == r)
    {
        IT[id] = val;
        return;
    }
    int mid = l + r >> 1;
    if(pos <= mid) Update(id * 2, l, mid, pos, val);
    else Update(id * 2 + 1, mid + 1, r, pos, val);
    IT[id] = max(IT[id * 2], IT[id * 2 + 1]);

}

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin);
    cin >> n;
    for(int i = 1; i <= n + 1; i++)
    {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a + 1, a + n + 2);
    for(int i = 1; i <= n; i++)
    {
        cin >> b[i];
    }
    sort(b + 1, b + n + 1);
    for(int i = 1; i <= n; i++) Update(1, 1, n, i, a[i + 1].first - b[i]);
    ans[a[1].second] = IT[1];
    for(int i = 2; i <= n + 1; i++)
    {
        Update(1, 1, n, i - 1, a[i - 1].first - b[i - 1]);
        ans[a[i].second] = IT[1];
    }
    for(int i = 1; i <= n + 1; i++)
    {
        cout << max(ans[i], 0) << ' ';
    }
}

Compilation message

ho_t1.cpp: In function 'void Update(int, int, int, int, int)':
ho_t1.cpp:16:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
     int mid = l + r >> 1;
               ~~^~~
ho_t1.cpp: In function 'int32_t main()':
ho_t1.cpp:27:39: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin);
                                ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 6 ms 376 KB Output is correct
18 Correct 6 ms 376 KB Output is correct
19 Correct 6 ms 504 KB Output is correct
20 Correct 6 ms 376 KB Output is correct
21 Correct 6 ms 376 KB Output is correct
22 Correct 6 ms 376 KB Output is correct
23 Correct 6 ms 376 KB Output is correct
24 Correct 6 ms 376 KB Output is correct
25 Correct 6 ms 376 KB Output is correct
26 Correct 6 ms 380 KB Output is correct
27 Correct 6 ms 380 KB Output is correct
28 Correct 6 ms 376 KB Output is correct
29 Correct 6 ms 376 KB Output is correct
30 Correct 6 ms 376 KB Output is correct
31 Correct 6 ms 504 KB Output is correct
32 Correct 6 ms 524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 4 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 376 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 6 ms 376 KB Output is correct
18 Correct 6 ms 376 KB Output is correct
19 Correct 6 ms 504 KB Output is correct
20 Correct 6 ms 376 KB Output is correct
21 Correct 6 ms 376 KB Output is correct
22 Correct 6 ms 376 KB Output is correct
23 Correct 6 ms 376 KB Output is correct
24 Correct 6 ms 376 KB Output is correct
25 Correct 6 ms 376 KB Output is correct
26 Correct 6 ms 380 KB Output is correct
27 Correct 6 ms 380 KB Output is correct
28 Correct 6 ms 376 KB Output is correct
29 Correct 6 ms 376 KB Output is correct
30 Correct 6 ms 376 KB Output is correct
31 Correct 6 ms 504 KB Output is correct
32 Correct 6 ms 524 KB Output is correct
33 Correct 165 ms 6956 KB Output is correct
34 Correct 169 ms 7160 KB Output is correct
35 Correct 163 ms 7032 KB Output is correct
36 Correct 171 ms 7416 KB Output is correct
37 Correct 163 ms 7544 KB Output is correct
38 Correct 176 ms 7516 KB Output is correct
39 Correct 193 ms 6776 KB Output is correct
40 Correct 162 ms 6520 KB Output is correct
41 Correct 167 ms 6648 KB Output is correct
42 Correct 168 ms 6620 KB Output is correct
43 Correct 169 ms 6648 KB Output is correct
44 Correct 162 ms 6264 KB Output is correct
45 Correct 162 ms 6392 KB Output is correct
46 Correct 165 ms 6388 KB Output is correct
47 Correct 155 ms 6136 KB Output is correct
48 Correct 165 ms 6136 KB Output is correct
49 Correct 164 ms 6776 KB Output is correct
50 Correct 169 ms 6776 KB Output is correct
51 Correct 166 ms 6652 KB Output is correct
52 Correct 167 ms 6816 KB Output is correct
53 Correct 171 ms 6776 KB Output is correct