답안 #503530

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
503530 2022-01-08T10:14:59 Z FronPaw Just Long Neckties (JOI20_ho_t1) C++14
9 / 100
97 ms 10728 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(0, a[i].first - b[i]));
    dr[n+1] = 0;
    for (int i = n;i>=1;--i)
        dr[i] = max(dr[i+1], max(0, 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 1 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 0 ms 324 KB Output is correct
6 Correct 1 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 1 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 0 ms 324 KB Output is correct
6 Correct 1 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 1 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 368 KB Output is correct
16 Correct 1 ms 328 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 404 KB Output is correct
20 Correct 2 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 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 2 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 0 ms 324 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 0 ms 324 KB Output is correct
6 Correct 1 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 1 ms 332 KB Output is correct
10 Correct 0 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 0 ms 332 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 368 KB Output is correct
16 Correct 1 ms 328 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 332 KB Output is correct
19 Correct 1 ms 404 KB Output is correct
20 Correct 2 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 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 1 ms 332 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 2 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 82 ms 10036 KB Output is correct
34 Correct 93 ms 10380 KB Output is correct
35 Correct 97 ms 10060 KB Output is correct
36 Correct 92 ms 10416 KB Output is correct
37 Correct 96 ms 10728 KB Output is correct
38 Correct 90 ms 10676 KB Output is correct
39 Correct 88 ms 9804 KB Output is correct
40 Correct 92 ms 9700 KB Output is correct
41 Correct 87 ms 9836 KB Output is correct
42 Correct 85 ms 9816 KB Output is correct
43 Correct 84 ms 9748 KB Output is correct
44 Correct 84 ms 9284 KB Output is correct
45 Correct 83 ms 9436 KB Output is correct
46 Correct 86 ms 9284 KB Output is correct
47 Incorrect 67 ms 8880 KB Output isn't correct
48 Halted 0 ms 0 KB -