ashdfioasd12367 @ 2023-04-02 20:27:40
这道题如果用sort的话,最后两个点会超时,但为什么开了o2之后就可以AC
by Milthm @ 2023-04-02 20:32:54
@ashdfioasd12367 因为O2会优化STL里的常数
by ud2_ @ 2023-04-02 20:53:40
不开优化的代码效率不可信。
by chenhongyicc @ 2023-04-08 12:51:50
@ashdfioasd12367 o2的话,sort依然做不了
by ashdfioasd12367 @ 2023-04-09 15:59:48
@henrychen310 别忘开o2
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[5000005];
int main()
{
int n,k;
scanf("%d%d",&n,&k);
for (int i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
sort(a,a+n);
printf("%d\n",a[k]);
}
by chenhongyicc @ 2023-04-15 11:08:37
@ashdfioasd12367 woc,还真能过,在下冒犯了。
by LIUSHUAI_LINWEIJI @ 2023-05-23 21:01:12
现在再开O2已经不行了,被制裁了 /tmp/compiler_79rfgnb7/src:2:9: 错误:‘#pragma GCC optimize’ is not allowed in online judge mode 2 | #pragma GCC optimize(2)