Advertisement
dahao

BAI3

Feb 22nd, 2020
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. typedef long long ll;
  6. typedef long double ld;
  7. typedef unsigned long long ull;
  8. typedef pair <ll, ll> ii;
  9. typedef pair <ll, ii> iii;
  10.  
  11. const ll N = 1e6 + 5;
  12. const ll INF = 1e9 + 7;
  13.  
  14. ll n, a[N];
  15.  
  16. int main() {
  17.     //freopen("CAU3.INP", "r", stdin);
  18.     //freopen("CAU3.OUT", "w", stdout);
  19.     ios_base::sync_with_stdio(false);
  20.     cin.tie(NULL);
  21.     cout.tie(NULL);
  22.     cin >> n;
  23.     for (ll i = 1; i <= n; i++) cin >> a[i];
  24.     //********************
  25.     ll max1 = 0, max2 = 0, max3 = 0;
  26.     for (ll i = 1; i <= n; i++) {
  27.         if (max1 < a[i]) {
  28.             max3 = max2;
  29.             max2 = max1;
  30.             max1 = a[i];
  31.         } else if (max2 < a[i]) {
  32.             max3 = max2;
  33.             max2 = a[i];
  34.         } else if (max3 < a[i]) max3 = a[i];
  35.     }
  36.     //********************
  37.     cout << max1 << " " << max2 << " " << max3;
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement