답안 #503532

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
503532 2022-01-08T10:16:51 Z FronPaw Just Long Neckties (JOI20_ho_t1) C++14
9 / 100
91 ms 11652 KB
#include <bits/stdc++.h>
#define mod 1000000007
#define int long long
// https://www.youtube.com/watch?v=t5GDacP_2pQ
using namespace std;
ifstream in ("film.in");
ofstream out ("film.out");
int pow (int a, int b)
{
    int rez = 1;
    while (b)
    {
        if (b&1)
            rez = (rez * a) % mod;
        a = (a * a) % mod;
        b>>=1;
    }
    return rez;
}
pair <int, int> a[200002];
int b[200001], n;
int ans[200001];
int st[200001];
int dr[200001];
void solve ()
{
    cin >> n;
    for (int i = 1;i<=n+1;++i)
    {
        cin >> a[i].first;
        a[i].second = i;
    }
    for (int i = 1;i<=n;++i)
        cin >> b[i];
    sort(a + 1, a + n + 2);
    sort(b + 1, b + n + 1);
    b[n+1] = a[n+1].first;
    for (int i = 1;i<=n;++i)
        st[i] = max(st[i-1], max(0LL, a[i].first - b[i]));
    dr[n+1] = 0;
    for (int i = n;i>=1;--i)
        dr[i] = max(dr[i+1], max(0LL, a[i+1].first - b[i]));
    for (int i = n + 1;i>=1;--i)
        ans[a[i].second] = max(dr[i], st[i-1]);
    for (int i = 1;i<=n+1;++i)
        cout << ans[i] << ' ';
    cout << '\n';
}
main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
}

Compilation message

ho_t1.cpp:49:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   49 | main ()
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 1 ms 460 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 368 KB Output is correct
31 Correct 1 ms 460 KB Output is correct
32 Correct 1 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 332 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 0 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 0 ms 332 KB Output is correct
17 Correct 1 ms 332 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 332 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 1 ms 460 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 368 KB Output is correct
31 Correct 1 ms 460 KB Output is correct
32 Correct 1 ms 460 KB Output is correct
33 Correct 78 ms 10692 KB Output is correct
34 Correct 91 ms 11200 KB Output is correct
35 Correct 86 ms 10832 KB Output is correct
36 Correct 84 ms 11292 KB Output is correct
37 Correct 87 ms 11652 KB Output is correct
38 Correct 82 ms 11496 KB Output is correct
39 Correct 81 ms 10600 KB Output is correct
40 Correct 79 ms 10572 KB Output is correct
41 Correct 80 ms 10672 KB Output is correct
42 Correct 81 ms 10532 KB Output is correct
43 Correct 77 ms 10564 KB Output is correct
44 Correct 79 ms 10092 KB Output is correct
45 Correct 78 ms 10196 KB Output is correct
46 Correct 78 ms 10160 KB Output is correct
47 Incorrect 62 ms 9668 KB Output isn't correct
48 Halted 0 ms 0 KB -