Submission

Status:

[PPPPPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: patty

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

Language: cpp

Time: 0.008 second

Submitted On: 2026-03-13 17:26:34

#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	long long 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;
}