洛谷 P5019 铺设道路
作者:互联网
题目传送门
解题思路:
AC代码:
1 #include<iostream> 2 #include<cstdio> 3 4 using namespace std; 5 6 int n,a[100001],u,o; 7 8 int main() { 9 scanf("%d",&n); 10 for(int i = 1;i <= n; i++) 11 scanf("%d",&a[i]); 12 o = a[1]; 13 for(int i = 2;i <= n; i++) { 14 u = o; 15 o= a[i]; 16 a[i] = o - u; 17 } 18 u = 0; 19 for(int i = 1;i <= n ;i++) 20 if(a[i] > 0) u += a[i]; 21 printf("%d",u); 22 return 0; 23 }
//NOIP提高 2018 Day1 T1
标签:洛谷,int,Day1,传送门,铺设,printf,P5019,include 来源: https://www.cnblogs.com/lipeiyi520/p/11267260.html