๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.61K subscribers
5.59K photos
3 videos
95 files
10.1K links
๐ŸšฉMain Group - @SuperExams
๐Ÿ“Job Updates - @FresherEarth

๐Ÿ”ฐAuthentic Coding Solutions(with Outputs)
โš ๏ธDaily Job Updates
โš ๏ธHackathon Updates & Solutions

Buy ads: https://telega.io/c/cs_algo
Download Telegram
Hey LinkedIn professionals,

I know how difficult it is for freshers to land a job in today's market. ๐Ÿง So, Dexian has come up with an excellent Work from home Opportunity. Yes, you heard that right! A work from home opportunity with a top e-commerce giant! ๐Ÿ’ป

โœ… The best part? Graduates from any field can apply! (2023,2024 graduates only)
Please reach out to me at sandeepana.chakra@dexian.com ๐Ÿš€ or you can DM me on LinkedIn to discuss further!! ๐Ÿ™‚

One interested comment will also fly; I will reach out to you. ๐Ÿ˜Ž
โœ… Role: Catalog Specialist
โœ… Mode: Work from Home.
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <bits/stdc++.h>
using namespace std;

int main(){
  
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N, Smax;
    if(!(cin >> N >> Smax)) return 0;
    vector<char> id(N);
    vector<int> E(N), R(N);
    for(int i = 0; i < N; i++){
        cin >> id[i] >> E[i] >> R[i];
    }

    vector<vector<int>> dp(N+1, vector<int>(Smax+1, 0));
    for(int i = 1; i <= N; i++){
        for(int w = 0; w <= Smax; w++){
            dp[i][w] = dp[i-1][w];
            if(w >= E[i-1])
                dp[i][w] = max(dp[i][w], dp[i-1][w - E[i-1]] + R[i-1]);
        }
    }

    int bestReward = dp[N][Smax];
    if(bestReward == 0){
        cout << -1 << "\n";
        return 0;
    }

    vector<int> chosen;
    int w = Smax;
    for(int i = N; i >= 1; i--){
        if(dp[i][w] != dp[i-1][w]){
            // task i-1 was used
            chosen.push_back(i-1);
            w -= E[i-1];
        }
    }
    reverse(chosen.begin(), chosen.end()); 

    int totalEffort = 0;
    for(int idx : chosen) totalEffort += E[idx];

    for(size_t i = 0; i < chosen.size(); i++){
        if(i) cout << ' ';
        cout << id[chosen[i]];
    }
    cout << "\n";
    cout << totalEffort << ' ' << bestReward << "\n";
    return 0;
}