Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- typedef unsigned long long ull;
- typedef pair <ll, ll> ii;
- typedef pair <ll, ii> iii;
- const ll N = 1e6 + 5;
- const ll INF = 1e9 + 7;
- ll n, a[N];
- int main() {
- //freopen("CAU3.INP", "r", stdin);
- //freopen("CAU3.OUT", "w", stdout);
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- cin >> n;
- for (ll i = 1; i <= n; i++) cin >> a[i];
- //********************
- ll max1 = 0, max2 = 0, max3 = 0;
- for (ll i = 1; i <= n; i++) {
- if (max1 < a[i]) {
- max3 = max2;
- max2 = max1;
- max1 = a[i];
- } else if (max2 < a[i]) {
- max3 = max2;
- max2 = a[i];
- } else if (max3 < a[i]) max3 = a[i];
- }
- //********************
- cout << max1 << " " << max2 << " " << max3;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement