Combothermal

Untitled

Jun 13th, 2020
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. #pragma GCC optimize ("O3")
  2. #pragma GCC target ("sse4")
  3.  
  4. #include <bits/stdc++.h>
  5.  
  6. using namespace std;
  7.  
  8. typedef long long ll;
  9. typedef long double ld;
  10. typedef complex<ld> cd;
  11.  
  12. typedef pair<int, int> pi;
  13. typedef pair<ll,ll> pl;
  14. typedef pair<ld,ld> pd;
  15.  
  16. typedef vector<int> vi;
  17. typedef vector<ld> vd;
  18. typedef vector<ll> vl;
  19. typedef vector<pi> vpi;
  20. typedef vector<pl> vpl;
  21. typedef vector<cd> vcd;
  22.  
  23. #define FOR(i, a, b) for (int i=a; i<(b); i++)
  24. #define F0R(i, a) for (int i=0; i<(a); i++)
  25. #define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
  26. #define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
  27.  
  28. #define sz(x) (int)(x).size()
  29. #define mp make_pair
  30. #define pb push_back
  31. #define f first
  32. #define s second
  33. #define lb lower_bound
  34. #define ub upper_bound
  35. #define all(x) x.begin(), x.end()
  36. #define ins insert
  37.  
  38. mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  39.  
  40. const int MOD = 1000000007;
  41. const char nl = '\n';
  42. const int MX = 100001; //check the limits, dummy
  43.  
  44. int main() {
  45. ios_base::sync_with_stdio(0); cin.tie(0);
  46.  
  47. int N; cin >> N;
  48. vi A(N); F0R(i, N) cin >> A[i];
  49. F0R(i, N) {
  50. if (A[i] > i+1 || (i > 0 && A[i] < A[i-1])) {
  51. cout << -1 << nl; return 0;
  52. }
  53. }
  54. vi B(N);
  55. queue<int> need;
  56. F0Rd(i, N) {
  57. if ((i > 0 && A[i] > A[i-1]) || (i == 0 && A[i] != 0)) {
  58. if (i != 0) {
  59.  
  60. B[i] = A[i-1];
  61. } else B[i] = 0;
  62. FOR(j, A[i-1]+1, A[i]) {
  63. need.push(j);
  64. }
  65. } else {
  66. if (sz(need) > 0) {
  67. B[i] = need.front(); need.pop();
  68. } else {
  69. B[i] = 1000000;
  70. }
  71. }
  72. }
  73.  
  74. F0R(i, N) {
  75. cout << B[i] << " ";
  76. }
  77. cout << nl;
  78.  
  79. return 0;
  80. }
  81.  
  82. // read the question correctly (ll vs int)
  83. // template by bqi343
Advertisement
Add Comment
Please, Sign In to add comment