Created
May 12, 2015 12:33
-
-
Save OmarJH/f6a3a5a8c2b523c248bd to your computer and use it in GitHub Desktop.
Sunset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
using namespace std; | |
int main() | |
{ | |
vector <int> a; | |
vector <int> ans; | |
int n,maxx=0,t; | |
cin >> t; | |
while (t--) | |
{ | |
cin >> n; | |
a.push_back(n); | |
} | |
maxx = 0; | |
for (int i = a.size() - 1; i >= 0; i--) | |
{ | |
if (a[i] > maxx) | |
{ | |
ans.push_back(a[i]); | |
maxx = a[i]; | |
} | |
} | |
for (int i = ans.size()-1; i >=0; i--) | |
{ | |
cout << ans[i]; | |
if (i!=0) | |
cout<< " "; | |
} | |
cin >> n; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment