Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- TASK:
- USER: gabriel90
- LANG: C++
- **/
- #include <bits/stdc++.h>
- using namespace std;
- #define forn(i, n) for(int i=0; i<(n); i++)
- #define readVec(v) forn(i, v.size()){cin >> v[i];}
- #define pb push_back
- #define mp make_pair
- #define MOD 1000000007
- #define f first
- #define s second
- typedef long long ll;
- typedef double ld;
- typedef long double lld;
- typedef pair<int, int> pii;
- typedef pair<ll, ll> pll;
- typedef vector<int> vi;
- typedef vector<ll> vl;
- typedef vector<bool> vb;
- typedef vector<pii> vpi;
- typedef vector<pll> vpl;
- typedef vector<vi> vii;
- //Printing pairs and vectors
- template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
- template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
- cout << ""; for(int i = 0; i < v.size(); i++) {if (i) cout << " "; cout << v[i];} return cout << "";
- }
- //2 147 483 647 int max
- //9 223 372 036 854 775 807 ll max
- void fast_io(){
- ios_base::sync_with_stdio(0);
- cin.tie(NULL);
- cout.tie(NULL);
- }
- void file_io(string taskname){
- string fin = taskname + ".in";
- string fout = taskname + ".out";
- const char* FIN = fin.c_str();
- const char* FOUT = fout.c_str();
- freopen(FIN, "r", stdin);
- freopen(FOUT, "w", stdout);
- fast_io();
- }
- int main(){
- fast_io();
- int n;
- cin >> n;
- vi l(n), r(n);
- vi a(n);
- forn(i,n){
- cin >> l[i];
- }
- forn(i,n){
- cin >> r[i];
- }
- vb used(n);
- int cnt = 0;
- for(int c=n; c>=1; c--){
- bool did = false;
- vi news;
- forn(i,n){
- if(l[i] == 0 && r[i] == 0 && !used[i]){
- cnt++;
- did = true;
- used[i] = true;
- a[i] = c;
- news.pb(i);
- }
- }
- for(int i: news){
- forn(x,i){
- if(!used[x]) r[x]--;
- }
- for(int x=i+1; x<n; x++){
- if(!used[x]) l[x]--;
- }
- }
- if(cnt==n){
- break;
- }
- if(!did){
- cout << "NO" << endl;
- return 0;
- }
- }
- cout << "YES" << endl;
- cout << a;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement