以下の内容はhttps://blog.hamayanhamayan.com/entry/2019/10/19/224640より取得しました。


Curtain [AtCoder Beginner Contest 143 A]

https://atcoder.jp/contests/abc143/tasks/abc143_a

解説

https://atcoder.jp/contests/abc143/submissions/8035132

カーテンを横並びにして横の長さを2Bにするのが隠せる最大になる。
なので、A-2Bが答えであるが、負になる可能性がある。
こういうときは下限でmaxを取るといい。
max(0, A-2B)が答え。

int A, B;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> A >> B;
    int ans = max(0, A - 2 * B);
    cout << ans << endl;
}



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

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