【題解】ZeroJudge d889: 2.黑傑克(jack)

【題目敘述】https://zerojudge.tw/ShowProblem?problemid=d889

#include <bits/stdc++.h>
using namespace std;

int n, a, t;

int main(){
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> a;
        if (a <= t+30) t = max(t+5, a+4);
    }
    if (t == 0) cout << 30 << "\n";
    else cout << t+31 << "\n";
}

分享本文 Share with friends