Ycy951130 @ 2024-07-17 18:47:40
#include<bits/stdc++.h>
using namespace std;
int k,a[5000050],n;
int main()
{
scanf("%d %d",n,k);
for(int i=0;i<=n;i++)
scanf("%d",a[i]);
sort(a,a+n);
cout<<a[k];
return 0;
}
求大神解答
by w_ann_k @ 2024-07-17 18:48:52
@Ycy951130 这道题得手写快排,可以自己看题解学习一下
by bowen666666 @ 2024-07-17 18:49:16
@w_ann_k
是的
by Ycy951130 @ 2024-07-17 18:50:47
@w_ann_k
@bowen666666
谢谢
by keep_shining @ 2024-07-17 18:53:31
@Ycy951130 scanf
写错了!
scanf("%d",a[i]);
应该是 scanf("%d",&a[i]);
,不会用就别用。
by keep_shining @ 2024-07-17 18:56:14
@w_ann_k @bowen666666 但是 sort
是可以过的,就比如我就用的 sort
。
by w_ann_k @ 2024-07-17 19:00:53
@keep_shining 应该是数据改了,我把我之前60分纯sort的代码交了确实也对了
by keep_shining @ 2024-07-17 19:01:06
@Ycy951130 还有你的 for
循环,应该从
by Ycy951130 @ 2024-07-17 19:21:21
@keep_shining
照着改了,全WA
by Ycy951130 @ 2024-07-17 19:21:58
已AC 此帖结
by bowen666666 @ 2024-07-19 12:29:57
@keep_shining 有的时候运气好就会过看数据水不水