Submission #909561

# Submission time Handle Problem Language Result Execution time Memory
909561 2024-01-17T09:13:43 Z a_l_i_r_e_z_a Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
3 ms 4700 KB
// In the name of God

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

#define pb push_back
#define S second
#define F first
#define mp make_pair
#define smax(x, y) (x) = max((x), (y))
#define smin(x, y) (x) = min((x), (y))
#define all(x) (x).begin(), (x).end()
#define len(x) ((int)(x).size())

const int maxn = 2e5 + 5;
const int inf = 1e9 + 7;
int n, b[maxn], ans[maxn];
pii a[maxn];

int32_t main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n;
    for(int i = 0; i < n + 1; i++){
        cin >> a[i].F;
        a[i].S = i;
    }
    for(int i = 0; i < n; i++) cin >> b[i];
    sort(b, b + n);
    sort(a, a + n + 1);
    multiset<int> st;
    for(int i = 0; i < n; i++) st.insert(max(0, a[i + 1].F - b[i]));
    for(int i = 0; i < n + 1; i++){
        ans[a[i].S] = (*st.rbegin());
        st.erase(st.find(max(0, a[i + 1].F - b[i])));
        st.insert(max(0, a[i].F - b[i]));
    }
    for(int i = 0; i < n + 1; i++) cout << ans[i] << ' ';
    cout << '\n';

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Runtime error 3 ms 4700 KB Execution killed with signal 6
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Runtime error 3 ms 4700 KB Execution killed with signal 6
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Runtime error 3 ms 4700 KB Execution killed with signal 6
5 Halted 0 ms 0 KB -