Codeforces Round #226 (Div. 2)A. Bear and Raspberry
2019-07-07 04:49
1276 查看
原文链接:http://www.cnblogs.com/Roly/p/3596603.html
/*
贪心的找到相邻两项差的最大值,再减去c,结果若是负数答案为0.
*/
1 #include <stdio.h> 2 #define maxn 105 3 int num[maxn]; 4 int main() 5 { 6 int n,c; 7 while(~scanf("%d%d",&n,&c)) 8 { 9 int ans = 0; 10 for(int i = 0;i < n;i++) 11 scanf("%d",num+i); 12 for(int i = 0;i < n-1;i++){ 13 int temp = num[i] - num[i+1]; 14 if(temp > ans) 15 ans = temp; 16 } 17 ans -= c; 18 if(ans>=0) 19 printf("%d\n",ans); 20 else 21 printf("0\n"); 22 } 23 }
转载于:https://www.cnblogs.com/Roly/p/3596603.html
相关文章推荐
- Codeforces Round #226 (Div. 2)A. Bear and Raspberry
- Codeforces Round #226 (Div. 2) A. Bear and Raspberry
- Codeforces Round #226 (Div. 2)A. Bear and Raspberry
- CF# IndiaHacks 2016 - Online Edition (Div. 1 + Div. 2) C - Bear and Up-Down
- Codeforces Round #356 (Div. 2)-A. Bear and Five Cards(模拟)
- IndiaHacks 2016 - Online Edition (Div. 1 + Div. 2) B. Bear and Compressing
- VK Cup 2016 - Round 1 (Div. 2 Edition) E. Bear and Contribution 单调队列
- VK Cup 2016 - Round 1 (Div. 2 Edition) B B. Bear and Displayed Friends 优先队列
- 【VK Cup 2016 - Round 1 (Div 2 Edition)A】【水题 暴力】Bear and Reverse Radewoosh 做题由易到难分高有难到易分高
- Codeforces Round #356 (Div. 1) D. Bear and Chase 暴力 ★ ★
- CodeForces #318 (div1) A.Bear and Poker
- Codeforces Round #356 (Div. 2) E. Bear and Square Grid 滑块
- Codeforces Round #356 (Div. 2)-B. Bear and Finding Criminals(模拟)
- Codeforces Round #356 (Div. 2)-C. Bear and Prime 100
- VK Cup 2016 - Round 1 (Div. 2 Edition) C. Bear and Forgotten Tree 3 构造
- 【VK Cup 2016 - Round 1 (Div 2 Edition)B】【水题】Bear and Displayed Friends 即时维护最大6个数
- Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 1) B. Bear and Blocks 水题
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) C - Bear and Colors
- Codeforces Round #356 (Div. 2) A. Bear and Five Cards 水题
- Codeforces Round #226 (Div. 2)B. Bear and Strings