79648315

Date: 2025-06-02 07:15:38
Score: 0.5
Natty:
Report link
#include <bits/stdc++.h>
using namespace std;
//Santa


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t; cin >> t;  // number of test cases
    while (t--) {
        int n; cin >> n;
        long long a; cin >> a;  // gift allocation can be large
        vector<int> score(n);
        for (int i = 0; i < n; i++) cin >> score[i];

        vector<long long> gifts(n, 1);

        // Left to right pass
        for (int i = 1; i < n; i++) {
            if (score[i] > score[i-1]) {
                gifts[i] = gifts[i-1] + 1;
            }
        }

        // Right to left pass
        for (int i = n - 2; i >= 0; i--) {
            if (score[i] > score[i+1]) {
                gifts[i] = max(gifts[i], gifts[i+1] + 1);
            }
        }

        long long total = accumulate(gifts.begin(), gifts.end(), 0LL);

        if (total <= a) {
            cout << "YES\n";
        } else {
            cout << "NO\n";
        }
    }

    return 0;
}
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: user30694948