标签:mat pac hid include ace for while string gif
题目链接: 放不出来
题目描述: 每个站点有a[i] 个 椰子, 相邻站点的距离给出, 每天需要b个椰子, 问是否能够坚持到终点。
解题思路: 水一波儿
代码:
#include <iostream> #include <cstdio> #include <string> #include <vector> #include <cstring> #include <iterator> #include <cmath> #include <algorithm> #include <stack> #include <deque> #include <map> #include <set> #include <queue> #define lson l, m, rt<<1 #define rson m+1, r, rt<<1|1 #define mem0(a) memset(a,0,sizeof(a)) #define sca(x) scanf("%d",&x) #define de printf("=======\n") typedef long long ll; using namespace std; const int maxn = 1e4; int a[maxn]; int c[maxn]; int main() { int t; sca(t); int n, b; while( t-- ) { scanf( "%d%d", &n, &b ); int sum = 0; for( int i = 0; i < n; i++ ) { sca(a[i]); } for( int i = 1; i < n; i++ ) { sca(c[i]); } sum += a[0]; int flag = 1; for( int i = 1; i < n; i++ ) { sum -= c[i]; if( sum < 0 ) { flag = 0; break; } sum += a[i]; } if( flag ) { printf( "Yes\n" ); } else { printf( "No\n" ); } } return 0; }
思考: 水水更健康, 就是这题敲的还是有点儿慢
标签:mat pac hid include ace for while string gif
原文地址:http://www.cnblogs.com/FriskyPuppy/p/7499468.html