Submission

Status:

[PPPP-SSSSSSSS]

Subtask/Task Score:

{0/100}

Score: 0

User: patty

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

Language: cpp

Time: 0.008 second

Submitted On: 2026-03-13 17:25:50

#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,profit=0,stock,before;
	cin >> n >> before;
	for(int i=1;i<n;i++) {
		cin >> stock;
		if(stock>before) profit+=stock-before;
		before = stock;
	}
	cout << profit;
}