-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStack.cpp
More file actions
92 lines (92 loc) · 1.44 KB
/
Copy pathStack.cpp
File metadata and controls
92 lines (92 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//#include<cstdio>
//#include<functional>
//#include<iostream>
//#include<vector>
//#include<stack>
//#include<set>
//#include<string>
//#define MAX_VAL 100010
//using namespace std;
//#pragma warning(disable:4996)
//int N;
//stack<int> s;
//int tree[MAX_VAL];
//void Update(int idx, int val)
//{
// while (idx<=MAX_VAL)
// {
// tree[idx] += val;
// idx += (idx&-idx);
// }
//}
//int get_c(int idx)
//{
// int sum = 0;
// while (idx>0)
// {
// sum += tree[idx];
// idx -= (idx&-idx);
// }
// return sum;
//}
//void Push(int num)
//{
// s.push(num);
// Update(num, 1);
//}
//int Pop()
//{
// if (s.empty())return -1;
// int top = s.top(); s.pop();
// Update(top, -1);
// return top;
//}
//int PeekMedian()
//{
// if (s.empty())return -1;
// int Rank = (1+s.size())/2;
// int left = 0, right = MAX_VAL;
// while (left<=right)
// {
// int mid = (left + right) / 2;
// if (get_c(mid)<Rank)
// {
// left = mid + 1;
// }
// else
// {
// right = mid-1;
// }
// }
// return left;
//}
//int main()
//{
// scanf("%d", &N);
// for (int i = 0; i < N; i++)
// {
// char cmd[50]; scanf("%s", cmd);
// if (cmd[1] == 'u')
// {
// int num; scanf("%d", &num);
// Push(num);
// }
// else if(cmd[1]=='o')
// {
// int r = Pop();
// if (r == -1)
// printf("Invalid\n");
// else
// printf("%d\n", r);
// }
// else
// {
// int r = PeekMedian();
// if (r == -1)
// printf("Invalid\n");
// else
// printf("%d\n", r);
// }
// }
// return 0;
//}