40分,TLE三个

P1168 中位数

大佬求助,这种写法过于简单
by Surpersolo @ 2019-08-15 16:49:58


,每次都排个序,难道不会超时??
by Computer1828 @ 2019-08-15 17:02:15


把sort移到for循环外面
by 学而思李老师 @ 2019-08-15 17:03:20


###### @[社会我猪酐](/space/show?uid=192631) 还是会错的
by Surpersolo @ 2019-08-15 17:13:09


抱歉,我看错题了,这题我的方法是这样的: ```cpp #include <cstdio> #include <vector> #include <algorithm> using namespace std; vector<int> a; using namespace std; int main(){ int n, tmp; scanf("%d", &n); for(int i = 1; i <= n; i ++){ scanf("%d", &tmp); a.insert(upper_bound(a.begin(), a.end(), tmp), tmp); if(i % 2 == 1){ printf("%d\n", a[(i - 1) / 2]); } } return 0; } ```
by 学而思李老师 @ 2019-08-15 17:15:16


~~STL大法好~~
by 学而思李老师 @ 2019-08-15 17:15:40


###### @[社会我猪酐](/space/show?uid=192631) 谢谢了,我看懂了
by Surpersolo @ 2019-08-15 17:27:03


###### 我这是枚举了n遍,时间复杂度O(n^n),超了
by Surpersolo @ 2019-08-15 17:28:07


|