ATS resume help
前往频道在 Telegram
WhatsApp Me https://wa.me/917674087200 ✅ ATS-Friendly Resumes ✅ Higher Interview Calls ✅ Free Tips + Templates
显示更多3 694
订阅者
-224 小时
-217 天
-8330 天
帖子存档
3 694
Greedy Man
#include <bits/stdc++.h>
using namespace std;
void func(int price[], int n)
{
if (n == 1)
return;
int i = 0, profit=0;
while (i < n - 1) {
while ((i < n - 1) && (price[i + 1] <= price[i]))
i++;
if (i == n - 1)
break;
int buy = i++;
while ((i < n) && (price[i] >= price[i - 1]))
i++;
int sell = i - 1;
profit = profit + price[sell] - price[buy];
}
cout << profit;
}
int main()
{
int n;
cin>>n;
int price[n];
for(int i=0;i<n;i++){
cin>>price[i];
}
func(price, n);
return 0;
}
Telegram:- @CodingPalace
