QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#46089#4443. Fight and upgrademiaomiaoziWA 2ms3744kbC++171.4kb2022-08-25 16:41:062022-08-25 16:41:08

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-25 16:41:08]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3744kb
  • [2022-08-25 16:41:06]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
// https://space.bilibili.com/672346917

#ifndef LOCAL
#define LOG(...) 42
#endif

#define fi first
#define se second
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

typedef long long LL;
typedef pair <int, int> PII;

constexpr int inf = 0x3f3f3f3f;
constexpr double EPS = 1e-8;
const double PI = acos(-1);

int multi_cases = 1;

void A_SOUL_AvA () {
    int n, k;
    LL m;
    cin >> n >> m >> k;

    vector <LL> a(n + 1);
    vector <LL> pre(n + 1);
    pre[0] = m;

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        pre[i] = pre[i - 1] + a[i];
    }

    int ok = 0;
    function <int(int, int)> dfs = [&](int sta, int res) -> int {
        if (sta <= n && !res) return 1;

        LL damage = pre[sta], mn = 0;

        for (int i = sta + 1; i <= n && i - sta <= k; i++) {
            mn = max(mn - a[i], a[i]);
            if (damage >= mn) {
                return dfs(i, n - i);
            }
        }
        return 0;
    };

    cout << (dfs(0, n) ? "YES" : "NO") << endl;
}

int main () {
    cin.tie(nullptr)->sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int T = 1;
    for (multi_cases && cin >> T; T; T--) {
        A_SOUL_AvA ();
    }

    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3744kb

input:

11
2 3
1
1
0
1
1
0
1 1 0 1 1
1 1 0 1 2
0 2 1 1 1
2 2
3
13 11 4
11 0 9
3
4 16 4
4 16 11
20 26 15 19 2
20 26 1 1 1
20 3000
84
457 496 168 403 335 978 274 926 716 862 844 815 775 20 742 714 316 767 243 149 506 117 44 781 147 391 407 192 260 551 216 939 622 680 502 925 525 666 722 747 295 173 843 973 16...

output:

YES
NO
NO
NO
NO
NO
YES
NO
NO
YES
YES

result:

wrong answer 1st lines differ - expected: 'NO', found: 'YES'