QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#556766#8586. Partyallaeben0 0ms3556kbC++14763b2024-09-10 20:44:142024-09-10 20:44:14

Judging History

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

  • [2024-09-10 20:44:14]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3556kb
  • [2024-09-10 20:44:14]
  • 提交

answer

#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;

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


    sort(arr, arr + n);

    int sum1 = 0, sum2 = 0;
    if (n % 2 == 0) {
      
        for (int i = n - (n % 2); i < n; ++i) {
            sum1 += arr[i];
        }
        cout <<  sum1 << endl;
    } else {
        // If n is odd, calculate both sums
        for (int i = n - ((n - 1) % 2 + 1); i < n; ++i) {
            sum1 += arr[i];
        }
        for (int i = n - ((n - 1) % 2); i < n; ++i) {
            sum2 += arr[i];
        }
        // Output the largest sum
        cout <<max(sum1, sum2) << endl;
    }

    return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

5
3 2 -1 4 5

output:

5

result:

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

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%