Số lớn thứ k
C++
include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, k;
cin >> n >> k;
vector<int> a(n);
for(int i = 0 ; i < n ; i++) cin >> a[i];
sort(a.begin(), a.end());
cout << a[n-k];
return 0;
}
...Xem thêm
Report
Bạn HDQM chép code bình luận ạ, bằng chứng:
Link bài nộp: https://lqdoj.edu.vn/submission/6515442
Link user: https://lqdoj.edu.vn/user/__HDQM__
...Xem thêm
Tìm vị trí (THTA Đà Nẵng 2025)
cày trâu vẫn AC:
Python
n=int(input())
demlen=1
sh=1
ds=[]
for i in range((1+n)*n//2):
for i in range(demlen):
ds.append(sh)
sh+=1
if demlen%2==1:
ds.reverse()
if n in ds:
print(ds.index(n)+1,demlen-ds.index(n))
break
demlen+=1
ds=[]
...Xem thêm