/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 284.0 KiB
#2 Runtime Error 236ms 256.77 MiB

Code

#include <stdio.h>

// Function to find the maximum possible sum of array D
int maxSum(int A[], int B[], int C[], int N) {
    int maxSum = 0;

    // Iterate through each index and select the maximum value from A, B, or C
    for (int i = 0; i < N; i++) {
        int currentSum = 0;
        if (A[i] >= B[i] && A[i] >= C[i])
            currentSum = A[i];
        else if (B[i] >= A[i] && B[i] >= C[i])
            currentSum = B[i];
        else
            currentSum = C[i];
        
        // Add the selected value to maxSum
        maxSum += currentSum;
    }

    return maxSum;
}

int main() {
    int T;
    scanf("%d", &T);

    while (T--) {
        int N;
        scanf("%d", &N);

        int A[N], B[N], C[N];
        
        for (int i = 0; i < N; i++)
            scanf("%d", &B[i]);
        for (int i = 0; i < N; i++)
            scanf("%d", &C[i]);

        printf("%d\n", maxSum(A, B, C, N));
    }

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1046 Maximum sum in 3-array
Contest
TLE_Headquarters - round #1
Language
C99 (GCC 13.2.0)
Submit At
2024-03-27 16:24:52
Judged At
2024-11-11 03:38:55
Judged By
Score
0
Total Time
236ms
Peak Memory
256.77 MiB