Submission #763020

# Submission time Handle Problem Language Result Execution time Memory
763020 2023-06-22T02:28:58 Z vjudge1 Just Long Neckties (JOI20_ho_t1) C++14
0 / 100
1 ms 340 KB
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("avx2,popcnt,lzcnt,abm,bmi,bmi2,fma,tune=native")
//#pragma expected_value
//#pragma isolated_call
//#pragma disjoint

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

#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define setpre(i) setprecision(i)<<fixed
#define foru(i, a, b) for(int i=a;i<=b;i++)
#define ford(i, a, b) for(int i=a;i>=b;i--)
#define mp make_pair
#define moo cout<<"moo "
#define fi first
#define se second

ll lmod = 1e9 + 7;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef pair<int, int> ii;
typedef pair<double, double> dd;

ii arr[200002];
int a[200001];
int maxpref[2][200002];
int pos[200002];

int main(){
	// freopen("input.inp", "r", stdin);
	// freopen("output.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n; cin >> n;
    foru(i, 1, n + 1){
        int x; cin >> x;
        arr[i] = mp(x, i);
    }
    foru(i, 1, n) cin >> a[i];
    sort(arr + 1, arr + n + 2);
    sort(a + 1, a + n + 1);
    foru(i, 1, n + 1) pos[arr[i].se] = i;
    maxpref[0][1] = arr[1].fi - a[1];
    maxpref[1][n + 1] = arr[n + 1].fi - a[n];
    foru(i, 2, n) maxpref[0][i] = max(maxpref[0][i - 1], arr[i].fi - a[i]);
    ford(i, n, 2) maxpref[1][i] = max(maxpref[1][i + 1], arr[i].fi - a[i - 1]);
    // foru(i, 0, 1){
    //     foru(j, 1, n + 1) cout << maxpref[i][j] << " ";
    //     cout << endl;
    // }
    cout << maxpref[1][2] << " ";
    foru(i, 2, n) cout << max(maxpref[0][pos[i] - 1], maxpref[1][pos[i] + 1])  << " ";
    cout << maxpref[0][n];
//	fclose(stdout);
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -