Advertisement
Guest User

Untitled

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