比赛 20251019新安模拟赛1 评测结果 AAAAAAAAAA
题目名称 铺设道路 最终得分 100
用户昵称 Alex 运行时间 0.053 s
代码语言 C++ 内存使用 3.82 MiB
提交时间 2025-10-19 08:58:19
显示代码纯文本
#include <bits/stdc++.h>

using namespace std;

int n, ans, pre;

int main()
{
	freopen("2018road.in", "r", stdin);
	freopen("2018road.out", "w", stdout);

	scanf("%d", &n);

	for (int i = 1; i <= n; ++i)
	{
		int x; scanf("%d", &x);
		if (x > pre) ans += x - pre;
		pre = x;
	}

	printf("%d\n", ans);
	
	return 0;
}