Submission #638811

# Submission time Handle Problem Language Result Execution time Memory
638811 2022-09-07T14:32:53 Z ghostwriter Just Long Neckties (JOI20_ho_t1) C++14
0 / 100
0 ms 340 KB
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include <debug.h>
#endif
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define _pb pop_back
#define _pf pop_front
#define lb lower_bound
#define ub upper_bound
#define mtp make_tuple
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll; typedef unsigned long long ull;
typedef double db; typedef long double ldb;
typedef pair<int, int> pi; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll;
typedef string str;
template<typename T> T gcd(T a, T b) { return (b == 0? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
#define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
#define EACH(i, x) for (auto &(i) : (x))
#define WHILE while
#define file "TEST"
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }
/*
    Tran The Bao
    CTL - Da Lat
    Cay ngay cay dem nhung deo duoc cong nhan
*/
const int N = 2e5 + 5;
int n, b[N], d[N], d1[N], ans[N];
pi a[N];
signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    // freopen(file".inp", "r", stdin);
    // freopen(file".out", "w", stdout);
    cin >> n;
    FOR(i, 1, n + 1) {
    	cin >> a[i].st;
    	a[i].nd = i;
    }
    FOR(i, 1, n) cin >> b[i];
    sort(a + 1, a + 2 + n);
    sort(b + 1, b + 1 + n);
    FOR(i, 1, n + 1) d[i] = max(d[i - 1], a[i].st - b[i]);
    FOS(i, n + 1, 1) d1[i] = max(d1[i + 1], a[i].st - b[i - 1]);
    FOR(i, 1, n + 1) ans[i] = max(d[i - 1], d1[i + 1]);
    FOR(i, 1, n + 1) cout << ans[i] << ' ';
    return 0;
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
ho_t1.cpp:44:5: note: in expansion of macro 'FOR'
   44 |     FOR(i, 1, n + 1) {
      |     ^~~
ho_t1.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
ho_t1.cpp:48:5: note: in expansion of macro 'FOR'
   48 |     FOR(i, 1, n) cin >> b[i];
      |     ^~~
ho_t1.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
ho_t1.cpp:51:5: note: in expansion of macro 'FOR'
   51 |     FOR(i, 1, n + 1) d[i] = max(d[i - 1], a[i].st - b[i]);
      |     ^~~
ho_t1.cpp:25:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   25 | #define FOS(i, r, l) for (int (i) = (r); (i) >= (l); --(i))
      |                               ^
ho_t1.cpp:52:5: note: in expansion of macro 'FOS'
   52 |     FOS(i, n + 1, 1) d1[i] = max(d1[i + 1], a[i].st - b[i - 1]);
      |     ^~~
ho_t1.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
ho_t1.cpp:53:5: note: in expansion of macro 'FOR'
   53 |     FOR(i, 1, n + 1) ans[i] = max(d[i - 1], d1[i + 1]);
      |     ^~~
ho_t1.cpp:24:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   24 | #define FOR(i, l, r) for (int (i) = (l); (i) <= (r); ++(i))
      |                               ^
ho_t1.cpp:54:5: note: in expansion of macro 'FOR'
   54 |     FOR(i, 1, n + 1) cout << ans[i] << ' ';
      |     ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -