Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main(){
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- int n;
- cin>>n;
- int k=0;
- vector <pair<int, int>> a(n);
- vector <pair<int, pair<int, int>>> b(n);
- for (int i=0; i<n; i++){
- cin>>a[i].first;
- a[i].second=i;
- }
- sort(a.begin(), a.end());
- for (int i=0; i<n; i++){
- for (int j=0; j<n; j++){
- if (a[i].first<a[j].first && a[i].second<a[j].second){
- if (b[i].first==0){
- b[i].second.first=a[j].second;
- b[i].first=a[j].first;
- }else{
- if (a[j].first>b[i].first && a[j].second>b[i].second.first){
- b[i].second.second=a[j].second;
- b[i].first=1000000001;
- }
- }
- }
- }
- }
- for (int i=0; i<n; i++){
- if (b[i].first==1000000001){
- cout<<a[i].second+1<<" "<<b[i].second.first+1<<" "<<b[i].second.second+1<<"\n";
- k=1;
- break;
- }
- }
- if (k==0){
- cout<<0<<"\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement