Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.25 KB | None | 0 0
  1. /**
  2. TASK:
  3. USER: gabriel90
  4. LANG: C++
  5. **/
  6. #include <bits/stdc++.h>
  7. using namespace std;
  8.  
  9. #define forn(i, n) for(int i=0; i<(n); i++)
  10. #define readVec(v) forn(i, v.size()){cin >> v[i];}
  11. #define pb push_back
  12. #define mp make_pair
  13. #define MOD 1000000007
  14. #define f first
  15. #define s second
  16.  
  17. typedef long long ll;
  18. typedef double ld;
  19. typedef long double lld;
  20. typedef pair<int, int> pii;
  21. typedef pair<ll, ll> pll;
  22. typedef vector<int> vi;
  23. typedef vector<ll> vl;
  24. typedef vector<bool> vb;
  25. typedef vector<pii> vpi;
  26. typedef vector<pll> vpl;
  27. typedef vector<vi> vii;
  28.  
  29. //Printing pairs and vectors
  30. template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
  31. template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
  32. cout << ""; for(int i = 0; i < v.size(); i++) {if (i) cout << " "; cout << v[i];} return cout << "";
  33. }
  34.  
  35. //2 147 483 647 int max
  36. //9 223 372 036 854 775 807 ll max
  37. void fast_io(){
  38. ios_base::sync_with_stdio(0);
  39. cin.tie(NULL);
  40. cout.tie(NULL);
  41. }
  42. void file_io(string taskname){
  43. string fin = taskname + ".in";
  44. string fout = taskname + ".out";
  45. const char* FIN = fin.c_str();
  46. const char* FOUT = fout.c_str();
  47. freopen(FIN, "r", stdin);
  48. freopen(FOUT, "w", stdout);
  49. fast_io();
  50. }
  51.  
  52. int main(){
  53. fast_io();
  54. int n;
  55. cin >> n;
  56. vi l(n), r(n);
  57. vi a(n);
  58.  
  59. forn(i,n){
  60. cin >> l[i];
  61. }
  62. forn(i,n){
  63. cin >> r[i];
  64. }
  65. vb used(n);
  66. int cnt = 0;
  67. for(int c=n; c>=1; c--){
  68. bool did = false;
  69. vi news;
  70. forn(i,n){
  71. if(l[i] == 0 && r[i] == 0 && !used[i]){
  72. cnt++;
  73. did = true;
  74. used[i] = true;
  75. a[i] = c;
  76. news.pb(i);
  77.  
  78. }
  79. }
  80. for(int i: news){
  81. forn(x,i){
  82. if(r[x] > 0) r[x]--;
  83. }
  84. for(int x=i+1; x<n; x++){
  85. if(l[x] > 0) l[x]--;
  86. }
  87. }
  88.  
  89. if(cnt==n){
  90. break;
  91. }
  92. if(!did){
  93. cout << "NO" << endl;
  94. return 0;
  95. }
  96. }
  97. cout << "YES" << endl;
  98. cout << a;
  99. return 0;
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement