Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
134065 蔡悠然 买卖股票的最佳时机 C++ 通过 100 0 MS 264 KB 285 2024-03-02 13:03:34

Tests(3/3):


#include<bits/stdc++.h> using namespace std; const int N=1e3+10; int p[N]; int n; int res; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d",&p[i]); } for(int i=1;i<n;i++){ if(p[i+1]-p[i]>0){ res+=p[i+1]-p[i]; } } printf("%d\n",res); return 0; }


测评信息: