Submission
Status:
[PPPPPPPPPPPPP]
Score: 100
User: Nightingale
Problemset: ซื้อขายหุ้นซีเค
Language: cpp
Time: 0.013 second
Submitted On: 2025-03-27 17:08:22
#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int a;
cin >> a;
vector<int> stock(a);
for(int i = 0; i < a; i++) {
cin >> stock[i];
}
int profit = 0;
for(int i = 1; i < a; i++) {
if(stock[i] > stock[i-1]) {
profit += stock[i] - stock[i-1];
}
}
cout << profit;
}