답안 #763045

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
763045 2023-06-22T02:43:16 Z vjudge1 Just Long Neckties (JOI20_ho_t1) C++14
100 / 100
76 ms 6892 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;
    foru(i, 1, n) maxpref[0][i] = max(maxpref[0][i - 1], arr[i].fi - a[i]);
    ford(i, n + 1, 1) 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;
    // }
    foru(i, 1, n + 1) cout << max(maxpref[0][pos[i] - 1], maxpref[1][pos[i] + 1])  << " ";
//	fclose(stdout);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 0 ms 340 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 0 ms 340 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 0 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 0 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
29 Correct 1 ms 340 KB Output is correct
30 Correct 1 ms 340 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 66 ms 6280 KB Output is correct
34 Correct 74 ms 6552 KB Output is correct
35 Correct 69 ms 6360 KB Output is correct
36 Correct 70 ms 6732 KB Output is correct
37 Correct 72 ms 6892 KB Output is correct
38 Correct 71 ms 6860 KB Output is correct
39 Correct 68 ms 5932 KB Output is correct
40 Correct 68 ms 5916 KB Output is correct
41 Correct 70 ms 6068 KB Output is correct
42 Correct 68 ms 6060 KB Output is correct
43 Correct 68 ms 5968 KB Output is correct
44 Correct 68 ms 5608 KB Output is correct
45 Correct 67 ms 5744 KB Output is correct
46 Correct 68 ms 5700 KB Output is correct
47 Correct 66 ms 5472 KB Output is correct
48 Correct 64 ms 5468 KB Output is correct
49 Correct 71 ms 6108 KB Output is correct
50 Correct 71 ms 6068 KB Output is correct
51 Correct 76 ms 6140 KB Output is correct
52 Correct 71 ms 6172 KB Output is correct
53 Correct 71 ms 6112 KB Output is correct