QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#95820#5590. Exponent ExchangeUsername#WA 2ms3480kbC++142.1kb2023-04-11 22:54:512023-04-11 22:54:52

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-11 22:54:52]
  • Judged
  • Verdict: WA
  • Time: 2ms
  • Memory: 3480kb
  • [2023-04-11 22:54:51]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;
using ld = long double;

int b, p;

vector<int> al, bb;

bool check(int mx) {
    int c1 = 0, c2 = 0;
    vector<int> a1 = al, a2 = bb;
    a1.push_back(0);
    a2.push_back(0);
    for (int i = 0; i < al.size(); ++i) {
        if (a1[i] < a2[i]) {
            if (c1 + a1[i] <= mx) {
                c1 += a1[i];
                int j = i;
                a2[i] += a1[i];
                while (a2[j] == b) {
                    a2[j++] = 0;
                    a2[j]++;
                }
            } else if (c2 + a2[i] <= mx) {
                c2 += a2[i];
                int j = i;
                a1[i] += a2[i];
                while (a1[j] == b) {
                    a1[j++] = 0;
                    a1[j]++;
                }
            } else return false;
        } else {
            if (c2 + a2[i] <= mx) {
                c2 += a2[i];
                int j = i;
                a1[i] += a2[i];
                while (a1[j] == b) {
                    a1[j++] = 0;
                    a1[j]++;
                }
            } else if (c1 + a1[i] <= mx) {
                c1 += a1[i];
                int j = i;
                a2[i] += a1[i];
                while (a2[j] == b) {
                    a2[j++] = 0;
                    a2[j]++;
                }
            } else return false;
        }
    }
    return c1 <= mx and c2 <= mx;
}

void test_case() {
    cin >> b >> p;
    al.resize(p);
    bb.resize(p);
    for (int &x : al)
        cin >> x;
    reverse(al.begin(), al.end());
    bb[0] = b - al[0];
    for (int i = 1; i < p; ++i)
        bb[i] = b - al[i] - 1;
    int l = 0, r = 1e9;
    while (l <= r) {
        int m = (l + r) / 2;
        if (check(m))
            r = m - 1;
        else l = m + 1;
    }
    cout << l << '\n';
}

signed main() {
    ios::sync_with_stdio(false); cout.tie(nullptr); cin.tie(nullptr);
    test_case();
    // int tc; cin >> tc;
    // while (tc--) {
    //     test_case();
    // }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3480kb

input:

10 5
4 2 7 8 6

output:

7

result:

ok single line: '7'

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3432kb

input:

2 100
1 1 1 1 0 0 1 1 1 0 1 1 1 0 0 1 0 0 1 0 0 1 1 1 0 1 1 0 1 1 1 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 0 0 1 0 1 0 1 0 0 1 1 0 0 0 0 1 0 1 1 1 1 0 1 1 0 1 1 0 0 0 0 1 1 1

output:

28

result:

wrong answer 1st lines differ - expected: '19', found: '28'