题解:P16426 「YLLOI-R4-T2」听妈妈的话
NaHCO3_Ciallo · · 题解
洛谷P16426
这道题就是一道典型的贪心,我们只需要让公鸡与母鸡相邻就好了喵。\
但是要注意的一点就是egg们的孵化时间不一定小于
最后累加起来就好了喵,还要注意开long long哦\ 代码如下
#include <bits/stdc++.h>
//天翼3G太快辣
#define pb push_back
#define endl '\n'
#define NaHCO3 return
#define qwq 0;
#define Skywings
#define maxn 1000010
#define int long long
using namespace std;
int n, t, a[maxn], ans;
signed main() {
cin >> n >> t;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i < n; i++) {
if (a[i] >= t || a[i+1] >= t) continue;
ans += (t - max(a[i], a[i+1]));
}
cout << ans << endl;
NaHCO3 qwq
}