fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. using ll = long long;
  5. using int128 = __int128;
  6.  
  7. #define all(v) (v).begin(), (v).end()
  8. #define sz(v) (int)(v).size()
  9. #define fi first
  10. #define se second
  11. #define debug(x) cerr << #x << " = " << x << '\n';
  12.  
  13. template <typename T>
  14. void read(T &x) {
  15. x = 0; bool f = 0; char c = getchar();
  16. while (!isdigit(c)) { if (c == '-') f = 1; c = getchar(); }
  17. while (isdigit(c)) { x = x * 10 + c - '0'; c = getchar(); }
  18. if (f) x = -x;
  19. }
  20.  
  21. template <typename T>
  22. void write(T x) {
  23. if (x < 0) { putchar('-'); x = -x; }
  24. char s[25]; int i = 0;
  25. do { s[i++] = x % 10 + '0'; x /= 10; } while (x);
  26. while (i) putchar(s[--i]);
  27. }
  28.  
  29. const int MOD = 1e9+7;
  30.  
  31. void solve() {
  32. int n; read(n);
  33. vector<int> a(n);
  34. for (int &x : a) read(x);
  35. sort(all(a));
  36.  
  37. for (int x : a) { write(x); putchar(' '); }
  38. putchar('\n');
  39. }
  40.  
  41. int main() {
  42. ios_base::sync_with_stdio(false); cin.tie(NULL);
  43.  
  44. #define TASK "ABC"
  45. if (fopen(TASK".INP", "r")) {
  46. freopen(TASK".INP", "r", stdin);
  47. freopen(TASK".OUT", "w", stdout);
  48. }
  49.  
  50. int tests = 1; // read(tests);
  51. while (tests--) solve();
  52.  
  53. #ifndef ONLINE_JUDGE
  54. cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
  55. #endif
  56.  
  57. return 0;
  58. }
Success #stdin #stdout 0.01s 5316KB
stdin
5
3 -1 2 4 5
stdout
-1 2 3 4 5