QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#610923#7037. Distanceucup-team4906#WA 0ms3532kbC++20823b2024-10-04 18:03:502024-10-04 18:03:50

Judging History

This is the latest submission verdict.

  • [2024-10-04 18:03:50]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3532kb
  • [2024-10-04 18:03:50]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;


void solve(void)
{
    int n;
    cin >> n;
    vi a(n + 2);
    for (int i = 1; i < n; i++)
        cin >> a[i];
    vl pre(n + 2);
    for (int i = 1; i < n; i++)
        pre[i] = pre[i - 1] + a[i];
    ll ans = 0, sum = 0;
    int u = 1;
    while (u <= n / 2)
    {
        ans += sum;
        cout << ans << " ";
        sum += pre[n - u] - pre[u - 1];
        ans += sum;
        cout << ans << " ";
        u++;
    }
    if (n & 1)
        cout << ans + sum << " ";
    cout << "\n";
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int T = 1;
    cin >> T;
    for (int i = 1; i <= T; i++)
        solve();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3532kb

input:

1
5
2 3 1 4

output:

0 10 20 34 48 

result:

wrong answer 1st lines differ - expected: '0 10 20 34 48', found: '0 10 20 34 48 '