Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
133831 林扬泉 买卖股票的最佳时机 C++ 通过 100 0 MS 260 KB 291 2024-03-02 09:44:06

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; }


测评信息: