Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
111239 | 朱悦晨 | 买卖股票的最佳时机 | C++ | 通过 | 100 | 0 MS | 256 KB | 360 | 2023-11-19 13:35:20 |
#include<bits/stdc++.h> using namespace std; int prices[1010],n; int fg() { int res = 0; for(int i=0;i<n-1;++i) { int temp = prices[i+1] - prices[i]; if(temp>0) res += temp; } return res; } int main() { cin>>n; for(int i=0;i<n;i++) cin>>prices[i]; cout<<fg()<<endl; return 0; }