QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#618343#9272. Fun at Luggage Claimartinz#WA 0ms3668kbC++171.4kb2024-10-06 21:10:312024-10-06 21:10:31

Judging History

This is the latest submission verdict.

  • [2024-10-06 21:10:31]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3668kb
  • [2024-10-06 21:10:31]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

using lli = int64_t;
using pii = pair<int, int>;
using vint = vector<int>;
using triple = pair<int, pii>;
using C = int;
using P = complex<C>;

const int MX = 505;
const int MOD = 1e9 + 7;

lli n, m;
lli res = 0;

void solve() {
    int n;
    cin >> n;

    lli a[n];
    lli mx = INT_MIN, imx = -1;
    for (int i = 0; i < n; i++) {
        cin >> a[i];

        if (a[i] >= mx) {
            mx = a[i];
            imx = i;
        }
    }

    lli b[n];
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }

    lli d = a[imx] - b[imx];

    if (d % 2 == 1) {
        cout << "No";
        return;
    }

    a[(n + imx + 1) % n] += d / 2;
    a[(n + imx - 1) % n] += d / 2;

    d = - a[(n + imx + 1) % n] + b[(n + imx + 1) % n];
    
    if (d < 0) {
        cout << "No";
        return;
    }

    a[(n + imx + 2) % n] += 2 * d;
    a[(n + imx + 1) % n] -= d;
    a[(n + imx + 3) % n] -= d;

    a[imx] = b[imx];
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            cout << "No";
            return;
        }
    }

    cout << "Yes";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t = 1;
    // cin >> t;

    while (t--) {
        solve();
        cout << '\n';
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
0 0 2
1 1 0

output:

Yes

result:

ok "Yes"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3668kb

input:

3
0 2 0
0 1 1

output:

No

result:

ok "No"

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3636kb

input:

4
0 100 0 10
33 40 33 4

output:

No

result:

wrong answer 1st words differ - expected: 'Yes', found: 'No'