fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <stdio.h>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7. struct Point{ int x,y; };
  8.  
  9. int main() {
  10. vector<Point> points;
  11. for (int i=0;i<100;i++) {
  12. //ランダムな点を生成
  13. Point pt = { rand() % (i+1), 0 };
  14. points.insert(upper_bound(points.begin(),points.end(),pt,
  15. [](const auto &lhs,const auto &rhs)->bool{return lhs.x<rhs.x;}),pt) ;
  16. }
  17. //要素を順に表示
  18. for(auto point : points) {cout << point.x << endl;}
  19. return 0;
  20. }
Success #stdin #stdout 0s 3468KB
stdin
Standard input is empty
stdout
0
0
0
0
0
0
0
1
1
1
1
1
2
2
2
2
2
3
3
3
3
3
4
5
5
5
6
6
7
7
7
7
7
7
8
8
8
8
9
11
11
11
12
13
14
14
14
14
15
16
16
16
17
18
18
19
19
20
20
20
21
21
21
21
22
23
23
23
24
24
25
26
26
26
27
28
32
32
34
34
36
39
39
43
47
50
51
51
52
53
62
62
63
64
67
68
70
75
93
94