๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.52K subscribers
5.55K photos
3 videos
95 files
9.58K 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
using namespace std;

#define ll long long

int main() {
    int numBombs;
    cin >> numBombs;

    vector<pair<int, int>> bombTimers(numBombs);
    for (int i = 0; i < numBombs; i++)
        cin >> bombTimers[i].first >> bombTimers[i].second;

    sort(bombTimers.begin(), bombTimers.end(), [](const auto &a, const auto &b) {
        return a.second < b.second;
    });

    ll currentTime = 0;
    for (int i = 0; i < numBombs; i++) {
        currentTime += bombTimers[i].first;
        if (currentTime > bombTimers[i].second) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << currentTime << endl;
    return 0;
}


UBER โœ