// Contest: AtCoder Beginner Contest 178 (https://atcoder.jp/contests/abc178)
// Problem: F: Contrast (https://atcoder.jp/contests/abc178/tasks/abc178_f)


// region boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n; cin >> n;
    vi a(n), b(n);
    trav(ai, a) cin >> ai, --ai;
    trav(bi, b) cin >> bi, --bi;

    multiset<int> r(all(b));
    multiset<pi> e;

    int i = 0;
    vi new_e;
    while (i < n) {
        int ai = a[i], c = 0;
        while (i < n && a[i] == ai)
            ++i, ++c;

        new_e.clear();
        rep(_, c) {
            if (*begin(r) < ai) {
                // Unmatched b_i < a_i
                new_e.emplace_back(*begin(r));
                r.erase(begin(r));
            } else if (*rbegin(r) > ai) {
                // Unmatched b_i > a_i
                new_e.emplace_back(*rbegin(r));
                r.erase(prev(end(r)));
            } else if (sz(e) && begin(e)->first < ai) {
                // Existing matching edge (a_j, b_j) s.t. a_j < a_i, b_j < a_i
                auto [bj, aj] = *begin(e);
                e.erase(begin(e));
                assert(*begin(r) == ai);
                r.erase(begin(r));
                new_e.emplace_back(bj);
                e.emplace(ai, aj);
            } else if (sz(e) && rbegin(e)->first > ai) {
                // Existing matching edge (a_j, b_j) s.t. a_j < a_i, b_j > a_i
                auto [bj, aj] = *rbegin(e);
                e.erase(prev(end(e)));
                assert(*begin(r) == ai);
                r.erase(begin(r));
                new_e.emplace_back(bj);
                e.emplace(ai, aj);
            } else {
                cout << "No\n";
                return 0;
            }
        }

        trav(bi, new_e)
            e.emplace(bi, ai);
    }

    vvi idx(n);
    rep(j, n)
        idx[a[j]].emplace_back(j);

    vi res(n);
    for (auto& [bi, ai] : e)
        res[idx[ai].back()] = bi, idx[ai].pop_back();

    cout << "Yes\n";
    trav(bi, res)
        cout << (bi + 1) << ' ';
    cout << '\n';

    return 0;
}


Measured memory_bytes: 25920