Submission #763029

# Submission time Handle Problem Language Result Execution time Memory
763029 2023-06-22T02:31:59 Z pdm Just Long Neckties (JOI20_ho_t1) C++14
0 / 100
15 ms 3668 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, 1, n) maxpref[0][i] = max(maxpref[0][i - 1], arr[i].fi - a[i]);
    ford(i, n + 1, 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);
}

Compilation message

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:34:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |  freopen("input.inp", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 3668 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 3668 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 3668 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -