Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <vector>
  4. #include <string>
  5. #include <cstdio>
  6. #include <algorithm>
  7. #include <cmath>
  8. #include <queue>
  9.  
  10. using namespace std;
  11.  
  12. int main() {
  13.   ios_base::sync_with_stdio(false);
  14.   cin.tie(0);
  15.   cin.tie(0);
  16.   int n, k;
  17.   bool t=false;
  18.   cin>>n;
  19.   vector<int> info;
  20.   vector<int> answer;
  21.   for (int i = 1; i <= n; i++) {
  22.     cin >> k;
  23.     info.push_back(k);
  24.   }
  25.   for (int i = n - 1; i >= 0; i--) {
  26.     k = info[i];
  27.     for (int y = i-1; y >= 0; y--) {
  28.       if (info[y] < k) {
  29.         answer.push_back(y);
  30.         t = true;
  31.         break;
  32.       }
  33.     }
  34.     if (t) {
  35.       t = false;
  36.       continue;
  37.     }
  38.     else {answer.push_back(-1);}
  39.   }
  40.   for (int k : answer)
  41.     cout << k << " ";
  42.   return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement