QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#556497#8586. Partyallaeben0 0ms3560kbC++14637b2024-09-10 18:57:302024-09-10 18:57:30

Judging History

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

  • [2024-09-10 18:57:30]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3560kb
  • [2024-09-10 18:57:30]
  • 提交

answer

#include <iostream>
#include <algorithm>

using namespace std;

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

    if (n == 1) {
        cout << max(0, a[0]) << endl;
        return 0;
    }
    
    if (n == 2) {
        cout << max({0, a[0], a[1]}) << endl;
        return 0;
    }

    int balakyjo[n];
    balakyjo[0] = max(0, a[0]);
    balakyjo[1] = max(balakyjo[0], a[1]);

    for (int i = 2; i < n; i++) {
        balakyjo[i] = max(balakyjo[i-1], a[i] + balakyjo[i-2]);
    }

    cout << balakyjo[n-1] << endl;

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

5
3 2 -1 4 5

output:

8

result:

wrong answer 1st lines differ - expected: '12', found: '8'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%