Submission

Status:
[PPPPPPPPPPPPP]

Score: 100

User: Cmoss9

Problemset: ซื้อขายหุ้นซีเค

Language: c

Time: 0.016 second

Submitted On: 2025-03-27 09:53:47

#include <stdio.h>
int main () {
    long long n;
    scanf("%lld",&n);
    long long i;
    long long arr[n];
    for (i = 0;i<n;i++) {
        scanf("%lld",&arr[i]);
    }
    long long profit = 0;
    for (i = 0;i<n-1;i++) {
        if (arr[i+1] > arr[i]) {
            profit += arr[i+1]  - arr[i];
        }
    }
    printf("%lld",profit);
    return 0;
}