답안 #977254

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
977254 2024-05-07T15:01:19 Z LOLOLO Just Long Neckties (JOI20_ho_t1) C++17
100 / 100
81 ms 10068 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
#define           f    first
#define           s    second
#define           pb    push_back
#define           ep    emplace
#define           eb    emplace_back
#define           lb    lower_bound
#define           ub    upper_bound
#define       all(x)    x.begin(), x.end()
#define      rall(x)    x.rbegin(), x.rend()
#define   uniquev(v)    sort(all(v)), (v).resize(unique(all(v)) - (v).begin())
#define     mem(f,x)    memset(f , x , sizeof(f))
#define        sz(x)    (int)(x).size()
#define  __lcm(a, b)    (1ll * ((a) / __gcd((a), (b))) * (b))
#define          mxx    *max_element
#define          mnn    *min_element
#define    cntbit(x)    __builtin_popcountll(x)
#define       len(x)    (int)(x.length())
 
const int N = 2e5 + 100;
pair <int, int> A[N];
int B[N], pr[N], ans[N];

ll solve() {
    int n;
    cin >> n;

    for (int i = 1; i <= n + 1; i++) {
        cin >> A[i].f;
        A[i].s = i;
    }

    for (int i = 1; i <= n; i++) {
        cin >> B[i];
    }

    sort(B + 1, B + 1 + n);
    sort(A + 1, A + 2 + n);
    for (int i = 1; i <= n; i++) {
        pr[i] = max(pr[i - 1], A[i].f - B[i]);
    }

    int cur = 0;
    for (int i = n + 1; i >= 1; i--) {
        ans[A[i].s] = max(cur, pr[i - 1]);
        cur = max(cur, A[i].f - B[i - 1]);     
    }

    for (int i = 1; i <= n + 1; i++)
        cout << ans[i] << " ";

    return 0;
}
 
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
 
    int t = 1;
    //cin >> t;
 
    while (t--) {
        solve();
        //cout << solve() << '\n';
    }
 
    return 0;
} 
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2408 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2508 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2388 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2408 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2508 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2388 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2568 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2564 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2408 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2508 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2388 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 1 ms 2568 KB Output is correct
18 Correct 1 ms 2396 KB Output is correct
19 Correct 1 ms 2396 KB Output is correct
20 Correct 1 ms 2396 KB Output is correct
21 Correct 1 ms 2396 KB Output is correct
22 Correct 1 ms 2396 KB Output is correct
23 Correct 1 ms 2396 KB Output is correct
24 Correct 1 ms 2396 KB Output is correct
25 Correct 1 ms 2396 KB Output is correct
26 Correct 1 ms 2396 KB Output is correct
27 Correct 1 ms 2564 KB Output is correct
28 Correct 1 ms 2392 KB Output is correct
29 Correct 1 ms 2396 KB Output is correct
30 Correct 1 ms 2396 KB Output is correct
31 Correct 1 ms 2396 KB Output is correct
32 Correct 1 ms 2396 KB Output is correct
33 Correct 66 ms 9448 KB Output is correct
34 Correct 70 ms 9696 KB Output is correct
35 Correct 68 ms 9324 KB Output is correct
36 Correct 68 ms 9812 KB Output is correct
37 Correct 70 ms 10068 KB Output is correct
38 Correct 74 ms 10008 KB Output is correct
39 Correct 67 ms 9160 KB Output is correct
40 Correct 68 ms 8988 KB Output is correct
41 Correct 68 ms 9172 KB Output is correct
42 Correct 69 ms 9028 KB Output is correct
43 Correct 67 ms 9040 KB Output is correct
44 Correct 65 ms 8788 KB Output is correct
45 Correct 67 ms 8784 KB Output is correct
46 Correct 68 ms 8772 KB Output is correct
47 Correct 63 ms 8780 KB Output is correct
48 Correct 63 ms 8592 KB Output is correct
49 Correct 69 ms 9300 KB Output is correct
50 Correct 75 ms 9552 KB Output is correct
51 Correct 70 ms 9324 KB Output is correct
52 Correct 81 ms 9216 KB Output is correct
53 Correct 69 ms 9244 KB Output is correct