Submission #1023791

# Submission time Handle Problem Language Result Execution time Memory
1023791 2024-07-15T06:38:19 Z vjudge1 Just Long Neckties (JOI20_ho_t1) C++17
0 / 100
0 ms 600 KB
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define ROF(i,m,n) for(int i=m;i<=n;i++)
#define vi vector<int>
#define pb push_back
#define alle(a) a.begin(),a.end()
#define rall(n) rbegin(n),rend(n)
#define int long long
#define vecs vector<int> 
#define ll long long
#define ss second 
#define ff first
const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int N = 2005;

void solve(){
    int n;
    cin >> n;
    int dp1[N], dp2[N],B[N], ans[N];
    pair<int,int> A[N];
    for(int i = 1; i <= n + 1; ++i) {
        cin >> A[i].first;
        A[i].second = i;
    }
    for(int i = 1; i <= n; ++i) {
        cin >> B[i];
    }
    sort(B + 1, B + n + 1);
    sort(A + 1, A + n + 2);
    for(int i = 1; i <= n; ++i) {
        dp1[i] = max(dp1[i - 1], A[i].first - B[i]);
    }
    
    for(int i = n + 1; i >= 2; --i) {
        dp2[i] = max(dp2[i + 1], A[i].first - B[i]);
    }

    for(int i = 1; i <= n + 1; ++i) {
        ans[A[i].second] = max(dp1[i], dp2[i]);
    }

    for(int i = 1; i <= n + 1; ++i) {
        cout << ans[i] << ' ';
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    while (t--) {
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -