Submission

Status:

[PPPPPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: meme_boi2

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

Language: cpp

Time: 0.008 second

Submitted On: 2026-03-18 18:03:33

#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    int n, mn = INT_MAX,ans = 0;
    cin >> n;
    vector<int> dp(n+1,0);
    for(int i =1 ; i <= n; i++){
        cin >> dp[i];
        if(i == 1 || dp[i]-dp[i-1] <= 0) continue;
        ans += dp[i] - dp[i-1];
    }
    cout << ans;
}

/*
c2_st66_stock

cd "c:\Users\RICOH-NB110\Desktop\Computer Programing\gchan\" ; if ($?) { g++ c2_st66_stock.cpp -o c2_st66_stock } ; if ($?) { .\c2_st66_stock}
*/