MuYuMC @ 2024-05-04 21:04:40
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;
int A[100000000];
int main()
{
int n,x,m,i;
cin >> n >> m;
for(i = 1;i <= n;i++)
{
cin >> x;
A[x]++;
}
x = -1;
for(i = 1;i <= 1000000000;i++)
{
if(A[i] != 0)
{
x++;
if(x == m)
{
cout << i;
break;
}
}
}
return 0;
}
by zhengpie @ 2024-05-04 21:31:53
A数组开大一点
by zhengpie @ 2024-05-04 21:32:35
你这样只能存a[0]到a[99999999]
by zhengpie @ 2024-05-04 21:33:08
再说了你开这么大干嘛,存不下去的
by MuYuMC @ 2024-05-05 13:52:36
@zhengpie ??
by zhengpie @ 2024-05-06 12:53:21
@MuYuMC ???
by zhengpie @ 2024-05-06 12:56:00
#include<bits/stdc++.h>
using namespace std;
int n,k,a[5000005];
int main()
{
cin>>n>>k;
for(int i = 1;i <= n;i++)
scanf("%d",&a[i]);
sort(a,a + n);
cout<<a[k];
return 0;
}
by MuYuMC @ 2024-05-07 11:56:52
@zhengpie 你这不是改的题解吗。。。。。
by zhengpie @ 2024-05-07 12:13:59
@MuYuMC 写的跟题解挺像而已
by MuYuMC @ 2024-05-07 12:15:05
@zhengpie 666
by zhengpie @ 2024-05-07 12:15:16
@MuYuMC 你咋不说a+b问题也一堆人改题解呢