提交记录 6874
提交时间 |
评测时间 |
2018-11-11 19:26:06 |
2020-08-01 00:52:15 |
#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1e5+7;
int n, ans;
int a[Maxn];
int stk[Maxn], sz;
int main()
{
scanf("%d", &n);
for(int i = 1; i <= n; ++i)
scanf("%d", a+i);
stk[++sz] = 0;
for(int i = 1; i <= n; ++i)
{
if(a[i] > stk[sz])
{
ans += a[i]-stk[sz];
stk[++sz] = a[i];
}
else
{
while(sz && stk[sz] >= a[i]) sz--;
stk[++sz] = a[i];
}
}
printf("%d\n", ans);
return 0;
}
Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
Testcase #1 | 36.96 us | 44 KB | Accepted | Score: 10 | 显示更多 |
Testcase #2 | 41.69 us | 44 KB | Accepted | Score: 10 | 显示更多 |
Testcase #3 | 43.66 us | 48 KB | Accepted | Score: 10 | 显示更多 |
Testcase #4 | 37.56 us | 48 KB | Accepted | Score: 10 | 显示更多 |
Testcase #5 | 39.2 us | 48 KB | Accepted | Score: 10 | 显示更多 |
Testcase #6 | 43.72 us | 48 KB | Accepted | Score: 10 | 显示更多 |
Testcase #7 | 67.79 us | 48 KB | Accepted | Score: 10 | 显示更多 |
Testcase #8 | 351.76 us | 84 KB | Accepted | Score: 10 | 显示更多 |
Testcase #9 | 1.65 ms | 240 KB | Accepted | Score: 10 | 显示更多 |
Testcase #10 | 3.263 ms | 432 KB | Accepted | Score: 10 | 显示更多 |
Judge Duck Online | 评测鸭在线
Server Time: 2024-12-05 10:05:46 | Loaded in 0 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠