以下の内容はhttps://blog.hamayanhamayan.com/entry/2021/05/30/225813より取得しました。


Friends and Travel costs [AtCoder Beginner Contest 203(Sponsored by Panasonic) C]

https://atcoder.jp/contests/abc203/tasks/abc203_c

解説

https://atcoder.jp/contests/abc203/submissions/23075028

int N, K;
vector<pair<ll, ll>> AB;
//---------------------------------------------------------------------------------------------------
ll solve() {
    ll yen = K;
    ll x = 0;
    fore(p, AB) {
        ll A = p.first;
        ll B = p.second;

        if (yen < A - x) return x + yen;
        yen -= A - x;

        x = A;
        yen += B;
    }
    return x + yen;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> K;
    rep(i, 0, N) {
        ll a, b; cin >> a >> b;
        AB.push_back({ a, b });
    }
    sort(all(AB));

    cout << solve() << endl;
}



以上の内容はhttps://blog.hamayanhamayan.com/entry/2021/05/30/225813より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14