RT

2 条评论

  • @ 2026-10-13 19:00:24
    #include <iostream>
    #include <vector>
    using namespace std;
    int main() {
        int N, K;
        if (!(cin >> N >> K)) return 0;
        vector<int> T(N);
        bool possible = true;
        for (int i = 0; i < N; ++i) {
            cin >> T[i];
            if (T[i] > K) {
                possible = false;
            }
        }
        if (!possible) {
            cout << "Oh,no!!!" << endl; //“,”报错是正常的
            return 0;
        }
        if (N == 0) {
            cout << 0 << endl;
            return 0;
        }
        int it = 0;
        int t = 0;
        for (int i = 0; i < N; ++i) {
            if (t + T[i] <= K) {
                t += T[i];
            } else {
                it++;
                t = T[i];
            }
        }
        cout << it << endl;
        return 0;
    }
    
  • @ 2026-4-10 18:59:14

    111111111111111111111111111111111111111111111111111111

  • 1

信息

ID
1275
时间
1000ms
内存
256MiB
难度
9
标签
递交数
11
已通过
4
上传者