题意:每10秒扫描一下盘子,查看盘子里面的面包个数,问你主角用两种吃法可能吃得的最少的面包。
1)任意吃。
2)每秒以恒定速度.
解题思路:暴力,找差值。
解题代码:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 // File Name: a.cpp 2 // Author: darkdream 3 // Created Time: 2015年04月18日 星期六 09时52分04秒 4 5 #include<vector> 6 #include<list> 7 #include<map> 8 #include<set> 9 #include<deque> 10 #include<stack> 11 #include<bitset> 12 #include<algorithm> 13 #include<functional> 14 #include<numeric> 15 #include<utility> 16 #include<sstream> 17 #include<iostream> 18 #include<iomanip> 19 #include<cstdio> 20 #include<cmath> 21 #include<cstdlib> 22 #include<cstring> 23 #include<ctime> 24 #define LL long long 25 26 using namespace std; 27 LL a[10005]; 28 int T; 29 int main(){ 30 freopen("A-large.in","r",stdin); 31 freopen("output","w",stdout); 32 scanf("%d",&T); 33 for(int ca = 1; ca <= T; ca ++){ 34 int n ; 35 LL ans1 = 0 ; 36 LL ans2 = 0 ; 37 LL mx = 0 ; 38 scanf("%d",&n); 39 for(int i= 1;i <= n;i ++){ 40 scanf("%lld",&a[i]); 41 if(i != 1 ) 42 if(a[i] < a[i-1]) 43 { 44 ans1 += a[i-1] - a[i]; 45 mx = max(a[i-1] - a[i],mx); 46 } 47 } 48 //printf("%lld\n",mx); 49 for(int i = 1;i < n;i ++) 50 { 51 if(a[i] < mx ) 52 ans2 += a[i]; 53 else ans2 += mx ; 54 } 55 printf("Case #%d: %lld %lld\n",ca,ans1,ans2); 56 57 } 58 return 0; 59 }
没有梦想,何谈远方