Submission #773063

# Submission time Handle Problem Language Result Execution time Memory
773063 2023-07-04T14:34:32 Z RecursiveCo Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
236 ms 26408 KB
// CF template, version 3.0

#include <bits/stdc++.h>

using namespace std;

#define improvePerformance ios_base::sync_with_stdio(false); cin.tie(0)
#define getTest int t; cin >> t
#define eachTest for (int _var=0;_var<t;_var++)
#define get(name) int (name); cin >> (name)
#define out(o) cout << (o)
#define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
#define sortl(name) sort((name).begin(), (name).end())
#define rev(name) reverse((name).begin(), (name).end())
#define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
#define decision(b) if (b){out("YES");}else{out("NO");}

#define int long long int

signed main() {
    improvePerformance;
    get(n);
    getList(n + 1, A);
    map<int, int> indices;
    vector<int> oldA;
    forto(n + 1, i) oldA.push_back(A[i]);
    getList(n, B);
    sortl(A);
    sortl(B);
    forto(n + 1, i) indices[A[i]] = i;
    vector<int> pref(n);
    vector<int> suf(n);
    forto(n, i) {
        if (i == 0) pref[i] = max(A[i] - B[i], 0ll), suf[i] = max(A[n] - B[n - 1], 0ll);
        else pref[i] = max(pref[i - 1], max(A[i] - B[i], 0ll)), suf[i] = max(suf[i - 1], max(A[n - i] - B[n - i - 1], 0ll));
    }
    forto(n + 1, i) {
        int ind = indices[oldA[i]];
        out(max(ind? pref[ind - 1]: 0ll, ind == n? 0ll: suf[n - ind - 1]));
        out(" ");
    }
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:10:23: warning: unnecessary parentheses in declaration of 'n' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
ho_t1.cpp:22:5: note: in expansion of macro 'get'
   22 |     get(n);
      |     ^~~
ho_t1.cpp:12:40: warning: unnecessary parentheses in declaration of 'A' [-Wparentheses]
   12 | #define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
      |                                        ^
ho_t1.cpp:23:5: note: in expansion of macro 'getList'
   23 |     getList(n + 1, A);
      |     ^~~~~~~
ho_t1.cpp:10:23: warning: unnecessary parentheses in declaration of 'a' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
ho_t1.cpp:12:76: note: in expansion of macro 'get'
   12 | #define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
      |                                                                            ^~~
ho_t1.cpp:23:5: note: in expansion of macro 'getList'
   23 |     getList(n + 1, A);
      |     ^~~~~~~
ho_t1.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
ho_t1.cpp:26:5: note: in expansion of macro 'forto'
   26 |     forto(n + 1, i) oldA.push_back(A[i]);
      |     ^~~~~
ho_t1.cpp:12:40: warning: unnecessary parentheses in declaration of 'B' [-Wparentheses]
   12 | #define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
      |                                        ^
ho_t1.cpp:27:5: note: in expansion of macro 'getList'
   27 |     getList(n, B);
      |     ^~~~~~~
ho_t1.cpp:10:23: warning: unnecessary parentheses in declaration of 'a' [-Wparentheses]
   10 | #define get(name) int (name); cin >> (name)
      |                       ^
ho_t1.cpp:12:76: note: in expansion of macro 'get'
   12 | #define getList(cnt, name) vector<int> (name); for (int _=0;_<(cnt);_++) { get(a); (name).push_back(a); }
      |                                                                            ^~~
ho_t1.cpp:27:5: note: in expansion of macro 'getList'
   27 |     getList(n, B);
      |     ^~~~~~~
ho_t1.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
ho_t1.cpp:30:5: note: in expansion of macro 'forto'
   30 |     forto(n + 1, i) indices[A[i]] = i;
      |     ^~~~~
ho_t1.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
ho_t1.cpp:33:5: note: in expansion of macro 'forto'
   33 |     forto(n, i) {
      |     ^~~~~
ho_t1.cpp:15:35: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   15 | #define forto(name, var) for (int (var) = 0; (var) < (name); (var)++)
      |                                   ^
ho_t1.cpp:37:5: note: in expansion of macro 'forto'
   37 |     forto(n + 1, i) {
      |     ^~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 516 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 1 ms 456 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 456 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 2 ms 468 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 320 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 516 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 1 ms 456 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 456 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1 ms 468 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 2 ms 468 KB Output is correct
30 Correct 1 ms 468 KB Output is correct
31 Correct 1 ms 468 KB Output is correct
32 Correct 1 ms 468 KB Output is correct
33 Correct 181 ms 24872 KB Output is correct
34 Correct 223 ms 25924 KB Output is correct
35 Correct 181 ms 25020 KB Output is correct
36 Correct 211 ms 25680 KB Output is correct
37 Correct 203 ms 26408 KB Output is correct
38 Correct 231 ms 26132 KB Output is correct
39 Correct 210 ms 24948 KB Output is correct
40 Correct 179 ms 24920 KB Output is correct
41 Correct 206 ms 25124 KB Output is correct
42 Correct 236 ms 25028 KB Output is correct
43 Correct 178 ms 24916 KB Output is correct
44 Correct 198 ms 24248 KB Output is correct
45 Correct 181 ms 24480 KB Output is correct
46 Correct 178 ms 24188 KB Output is correct
47 Correct 98 ms 14992 KB Output is correct
48 Correct 101 ms 15040 KB Output is correct
49 Correct 233 ms 25720 KB Output is correct
50 Correct 225 ms 25652 KB Output is correct
51 Correct 182 ms 25640 KB Output is correct
52 Correct 214 ms 25632 KB Output is correct
53 Correct 189 ms 25620 KB Output is correct