• VNOJ
  • Home
  • PRoblems
  • Submissions
  • Users
    >
    • Organizations
  • Contests
  • Wiki
  • About
    >
    • Cpp Refference
    • Python Refference
    • FAQ
    • Custom checker
    • Tag
    • Judges
    • Devlog
    • Github
    • Tickets
    • Thư viện đề thi
    • Đề xuất contest
  • Tạp chí
    • Theme
    • Language VI EN
Log in  or  Sign up

K31huynhphucdat

  • About
  • Blogs

Problems solved: 42
Rank by points: #5540
Total points: 12.27
Contribution points: -21

View submissions

From Trường THPT chuyên Hoàng Lê Kha, Tây Ninh

About

include<bits/stdc++.h>

using namespace std;

define int long long

signed main() { iosbase::syncwith_stdio(false); cin.tie(nullptr);

int n, k, m;
cin >> n >> k >> m;

vector<int> a(n);
for(int &x : a) cin >> x;

sort(a.begin(), a.end());

int l = 0, r = n - 1;
int pair = 0;

while(l < r)
{
    if(a[l] + a[r] <= m)
    {
        pair++;
        l++;
        r--;
    }
    else r--;
}

int take_pair = min(pair, k);
int rem_trip = k - take_pair;

int ans = take_pair * 2 + min(rem_trip, n - 2 * pair);

cout << ans << "\n";

}

Badges & Awards

This user has not earned any badges or awards.

«    »
Sun
Mon
Tues
Wed
Thurs
Fri
Sat
Less
More

proudly powered by DMOJ | follow us on Github and Facebook