fork download
  1. /*
  2.   Cred : SunnyYeahBoi
  3.   It's my last chance (⌐■_■)
  4.   Problem :
  5. */
  6.  
  7. #include<bits/stdc++.h>
  8.  
  9. using namespace std;
  10.  
  11. #define int long long
  12. #define double long double
  13. #define endl "\n"
  14. #define NAME "a"
  15.  
  16. const int MAXN = 1e6 + 5;
  17. const int inf = 1e18;
  18. const int MOD = 1e9 + 7;
  19.  
  20. void FileInput(){
  21. if(fopen(NAME".inp" , "r") == NULL)
  22. freopen(NAME".inp" , "w" , stdout);
  23. freopen(NAME".inp" , "r" , stdin);
  24. freopen(NAME".out" , "w" , stdout);
  25. }
  26.  
  27. int n;
  28. int a[MAXN];
  29.  
  30. void solve(){
  31. cin >> n;
  32. for(int i = 1 ; i <= n ; i++)
  33. cin >> a[i];
  34.  
  35. // sắp xếp tăng dần ()
  36. sort(a + 1 , a + 1 + n);
  37. // a - con trỏ chỉ tới vị trí 0
  38. // a + 1 -> vị trí 1
  39. // a + 1 + -> vị trí n
  40. // sort(a , a + n) - sort từ 0 đến n - 1
  41. // a1 <= a2 <= a3 <= a4 <= ... <= an
  42.  
  43. if(n % 2 == 1)
  44. cout << a[n / 2 + 1] << endl;
  45. else cout << ((double)a[n / 2] + a[n / 2 + 1]) / 2 << endl;
  46. }
  47.  
  48. int32_t main(){
  49. FileInput();
  50. ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  51. int t = 1;
  52. // cin >> t;
  53. while(t--)
  54. solve();
  55. return 0;
  56. }
  57.  
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
Standard output is empty