답안 #773060

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
773060 2023-07-04T14:32:46 Z RecursiveCo Just Long Neckties (JOI20_ho_t1) C++14
0 / 100
1 ms 212 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[oldA[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[oldA[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) {
      |     ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -