其他分享
首页 > 其他分享> > NOIP2018DAY1铺设道路(贪心)

NOIP2018DAY1铺设道路(贪心)

作者:互联网

NOIP2018 铺设道路

传送门:https://www.luogu.org/problem/P5019
解题报告
序言

三个小时就推了一道题可给我牛x坏了 (▼へ▼メ)
不写写过程都对不起我这三个小时的脑残历程=,=

心路

最后成品如下↓

#include<bits/stdc++.h>
using namespace std;
const int N = 1e5;
#define fr(i,n) for(int i = 1; i <= n; i++)
long long n,m,num,minx = INT_MAX,len,ans;
long long a[N],b[N],bj[N];
int main()
{
    ios::sync_with_stdio(false);
    cin >> n;
    fr(i,n){
      cin >> a[i];

      b[i] = a[i] - a[i - 1]; 
     }
    fr(i,n)  if(b[i] > 0) ans += b[i];
    cout << ans;
    return 0;
}

~~对 ,三个小时的比赛我就写了这一道题……(猛男落泪嘤嘤嘤

看题解无脑直接交了积木大赛得了90emmm一看题干妈呀这不是我最开始做铺设道路的思路吗……

猛男落泪x2~~

标签:fr,猛男,int,st,NOIP2018DAY1,铺设,贪心
来源: https://www.cnblogs.com/phemiku/p/11766447.html