Advertisement
ekzolot

Untitled

Dec 19th, 2021
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5. int main(){
  6.     ios::sync_with_stdio(0);
  7.     cin.tie(0);
  8.     cout.tie(0);
  9.     int n;
  10.     cin>>n;
  11.     int k=0;
  12.     vector <pair<int, int>> a(n);
  13.     vector <pair<int, pair<int, int>>> b(n);
  14.     for (int i=0; i<n; i++){
  15.         cin>>a[i].first;
  16.         a[i].second=i;
  17.     }
  18.     sort(a.begin(), a.end());
  19.     for (int i=0; i<n; i++){
  20.         for (int j=0; j<n; j++){
  21.             if (a[i].first<a[j].first && a[i].second<a[j].second){
  22.                 if (b[i].first==0){
  23.                     b[i].second.first=a[j].second;
  24.                     b[i].first=a[j].first;
  25.                 }else{
  26.                     if (a[j].first>b[i].first && a[j].second>b[i].second.first){
  27.                         b[i].second.second=a[j].second;
  28.                         b[i].first=1000000001;
  29.                     }
  30.                 }
  31.             }
  32.         }
  33.     }
  34.     for (int i=0; i<n; i++){
  35.         if (b[i].first==1000000001){
  36.             cout<<a[i].second+1<<" "<<b[i].second.first+1<<" "<<b[i].second.second+1<<"\n";
  37.             k=1;
  38.             break;
  39.         }
  40.     }
  41.     if (k==0){
  42.         cout<<0<<"\n";
  43.     }
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement