fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. struct fract
  5. {
  6. int number;
  7. int time;
  8. };
  9.  
  10. void out_mas (fract m[], int n)
  11. {
  12. for (int i=0; i<n; ++i)
  13. {
  14. cout<<m[i].number<<' ';
  15. }
  16.  
  17. }
  18.  
  19. void inp_mas(fract m[], int & n)
  20. {
  21. cin >> n;
  22. for (int i=0; i<n; ++i)
  23. {
  24. cin >> m[i].number >> m[i].time;
  25. }
  26. }
  27.  
  28. bool comp(fract n1, fract n2)
  29. {
  30. if (n1.time < n2.time) return true;
  31. return false;
  32. }
  33.  
  34. fract mas[100000];
  35.  
  36. int main()
  37.  
  38. {
  39. //ios_base::sync_with_stdio(0);
  40. //cin.tie(0);
  41. //cout.tie(0);
  42. int n;
  43. inp_mas(mas,n);
  44. sort(mas,mas+n,comp);
  45. out_mas(mas,n);
  46. return 0;
  47. }
Success #stdin #stdout 0s 5584KB
stdin
3
3 6
1 12
2 4
stdout
2 3 1